Sometimes, when copying a shell script edited on a Windows machine to a linux machine, you will have the an issue relating to a “bad interpreter”. This can be caused by Windows CRLF vs Linux CR. A simple fix is to use the following perl command on the file.
perl -i -pe's/\r$//;' filename.sh
(filename.sh is the name of the file to be fixed)