/bin/bash^M: bad interpreter: No such file or directory
If you get a /bin/bash^M: bad interpreter: No such file or directory or similar error it’s likely caused by a format incompatibility if you created or edited your shell script in Windows.
^M is a carriage return character. Linux uses the line feed character to mark the end of a line, whereas Windows uses the two-character sequence CR LF. Your file has Windows line endings, which is confusing Linux and causing the error.
There are several different ways of fixing this, but one of the easiest that allows you to fix the file in place is to install tofrodos
apt-get install tofrodos
to use it
This should fix the issue.