/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.

The ^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

fromdos filename

This should fix the issue.



You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.