Bash, Bad Interpreter

I recently came across:

/bin/bash^M: bad interpreter: No such file or directory

When trying to run a bash script that someone else had edited. This most commonly happens on UNIX systems if the file has been edited on MS-DOS or Mac. The cure for this is to run a simple perl script:

#!/usr/bin/perl -pi

Save as, chmod +x and then run like:

./ filetoconvert.txt


Leave a Reply

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