dos2unix: removing CRLF characters

If you have just copied a script created/edited from Windows text editors, and tried to run the script in Linux. You get below:

[anthony@fc18 tested_examples]$ ./ 
bash: ./ /bin/bash^M: bad interpreter: No such file or directory

Now try to confirm your text file content:

[anthony@fc18 tested_examples]$ file Bourne-Again shell script, ASCII text executable, with CRLF line terminators

if you get those CRLF line terminators, you will need to remove them.
Easiest way is to install the dos2unix package from YUM and run as below:

[anthony@fc18 tested_examples]$ dos2unix 
dos2unix: converting file to Unix format ...

And you will have your file clean.

No comments: