Tag Archives: fix

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:

1
2
#!/usr/bin/perl -pi
s/\n/\r\n/;

Save as unix2dos.pl, chmod +x unix2dos.pl and then run like:

./unix2dos.pl filetoconvert.txt

Simples!