Script format of the--/bin/bash^m: there is no file or directory

Source: Internet
Author: User

The bash script under Linux does not support line breaks \r , and if you run a file that is copied from Windows, you /bin/bash^M: 坏的解释器: 没有那个文件或目录 may want to check if the file format is incorrect.

If this is a format problem, there are two ways:

First, find the replacement method

  • First step: cat -A filename view ' \ r \ 空白符, n \ 会显示为 r \ ,而 会显示为 ^m '.
  • Step two: sed -i ‘s/\r$//‘filename replace all \r characters.

Ii. Vim Reset Document Format

  • The first step: :set ff? look at the file format, you can see fileformat=dos such a hint.
  • Second step: :set ff=unix cast to UNIX format.
  • Step three: :wq Save the exit.

Then run again to see if the same error has occurred, and if it is still wrong, check the syntax and the related commands correctly.

Reference:

  • Http://www.2cto.com/os/201310/252970.html

  • http://blog.csdn.net/yongan1006/article/details/8142527

Script format of the--/bin/bash^m: there is no 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.