bad interpreter: /bin/sh^M: no such file or directory solve problem

In this tutorial, How to solve bad interpreter when running the shell exit with “bad interpreter: /bin/sh^M: no such file or directory“. I will be using three methods. Linux the essential for DevOps Roles.

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

Method 1: Using vim editor

Open vim and insert the following command

:set fileformat=unix
:x

Or

:set ff=unix
:x

Method 2: Using sed command

[huupv@huupv devopsroles]$ sed -i 's/\r//' FILE_NAME

Method 3: I Using dos2unix command

[huupv@huupv devopsroles]$ dos2unix FILE_NAME

Conclusion

Thought the article, You have solved the problem “bad interpreter: /bin/sh^M: no such file or directory” as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology, especially Devops Skill such as Docker, vagrant, git, and so forth. I like open-sources, so I created DevopsRoles.com to share the knowledge I have acquired. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.