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

While running a script in Linux, if you encounter an error such as :

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

The error is due to incorrect format of the script. Most probably when the script is created in Windows and transferred to Linux.
The script might have a dos line ending file. The clue is the ^M

Inorder to resolve this error:

Open the script in Linux using vim editor,
 enter in vi command mode (key ESC), then type this:

:set fileformat=unix
 
Finally save it
:x! or :wq!

Thats it! Try running the script again and the error would have disappeared.

 

Comments

Popular posts from this blog

CDbConnection failed to open the DB connection mysql 8

Send mail from Oracle Solaris OS with attached files