Tuesday, September 09, 2008

BASH: bad interpreter: No such file or directory

-bash: ./execute.sh: /usr/bash^M: bad interpreter: No such file or directory


Dos text files use \r\n (0xD 0xA) as their end of line characters. Unix text files use \n (0xA) as their end of line character. What happened here is I had a file in dos text format, and tried to execute it in bash. the ^M you see above is saying "It wasn't expecting the \r character".

Solution:

use dos2unix
[user@linux1 ~] dos2unix execute.sh
dos2unix: converting files execute.sh to UNIX format...

No comments: