/bin/bash^M: bad interpreter: No such file or directory is a error thrown by Linux and Mac OSX operating systems when a Shell script is executed which was created in Windows environment. This happen because of the difference new line charters used by Windows and Linux operating systems. Window use \n\r for new line where as Linux use only \n. To fix this error either create your script in a Linux environment or use the following command.
sed -i -e 's/\r$//' SCRIPT_NAME.sh
Second ways is to open the file in gedit or any text editor in Linux and Save As... the file to a new file.
If you are on Windows, open you file in notepad++ go to Edit → EOL Conversion → UNIX/OSX Format. This is automatically solve the new line character issue.
Above image is taken from Stackoverflow.com