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]$ ./getinfo.sh 
bash: ./getinfo.sh: /bin/bash^M: bad interpreter: No such file or directory

Now try to confirm your text file content:

[anthony@fc18 tested_examples]$ file getinfo.sh 
getinfo.sh: 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 getinfo.sh 
dos2unix: converting file getinfo.sh to Unix format ...

And you will have your file clean.

No comments: