I use shell scripts for a few jobs.
Recently I rebuilt a laptop and installed a few scripts from a working machine. The other day I went to run one of the scripts from a command line and got the following:
/bin/bash^M: bad interpreter: No such file or directory
Now the new machine had an identical setup to the old and the script I was trying to run had the right permissions(and of course ran perfectly on the old machine), so the problem had to lie with the formatting of the script file ( and the ^M was a bit of a hint too?). Somehow the file transfer had corrupted the script file and trying to edit it didn't fix it.
A simple fix.
I used the following:
sed -i -e 's/\r$//' myfile.sh
The file then ran perfectly.