Error message after shell script execution "/bin/bash^m:bad interpreter:no such file or dire" workaround

Source: Internet
Author: User

In this case, it is usually a shell script written under window and copied to the Linux machine for execution to occur.

The reason is:

The end of each line under Windows is \n\r, and the end of the file under Linux is \ n

This allows window to write an edited shell script when it is copied to Linux

The end of each line will be more than one character. \ r

This \ r character will be displayed as ^m

So the error message "/bin/bash^m:bad interpreter:no such file or dire" appears,

It literally means/bin/bash^m: Bad interpreter: no file or directory.

Workaround:

Terminal execution

Sed-i ' s/\r$//' filename #flename即shell脚本文件名

This command will change the character ending with \ r to blank.

Error message after shell script execution "/bin/bash^m:bad interpreter:no such file or dire" workaround

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.