If you happen to occur in the following error:
/bin/bash^M: bad interpreter: No such file or directory
your bash script likely includes a carriage return (\r
) – Windows style – as well as a line feed (\n
).
So, delete all carriage returns within the script:
~$ sed -i -e 's/\r$//' <script_name>.sh