Illegal option when executing a script

Illegal option when executing a script

Sometimes when you run a script, you get this this error like set: Illegal option -:

Run

sh filename

Error

: not found: 2:
: not found: 4:
filename: 6: set: Illegal option -

This means there is something wrong with the line endings in your script. This can easily be resolved by running this:

Run

sed -i 's/\r$//' filename

After that rerun your script.