Resolve "/bin/bash^m:bad interpreter:no such file or directory"

Source: Internet
Author: User

The main reason for this error when executing shell scripts is that the shell script file is in DOS format, that is, the end of each line is identified by \ r \ n, and the end of the file line in UNIX format is identified by \ n.
There are several ways to see if the script file is in DOS or UNIX format.
(1) cat-a filename from the display results can be judged that the DOS format of the file line tail for the ^m$,unix format of the file line end is $.
(2) od-t x1 filename If you see 0d 0a characters in the output, the file is in DOS format, and if only 0a is the UNIX format.
(3) VI filename Open file, execute: Set FF, if the file is in DOS format shown as Fileformat=dos, if Unxi is displayed as Fileformat=unix.

Workaround:
(1) using the Linux command Dos2unix filename to convert files directly to UNIX format
(2) Use the SED command sed-i "s/\r//" filename or sed-i "s/^m//" filename to replace the end character directly with the UNIX format
(3) VI filename Open file, execute: Set Ff=unix set file for Unix, then execute: WQ, save to UNIX format.

Resolve "/bin/bash^m:bad interpreter:no such file or directory"

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.