Shell foot This report wrong line break syntax error near unexpected token \ r

Source: Internet
Author: User

Sometimes some of the improperly processed SH script files in Windows are placed under Linux to perform an error, prompting for a newline character, mainly because the end of the EOL line under window is "\ r \ n" two characters, while Linux,unix is "\ n".


The following VIM commands are confirmed.

: E ++ff=unix% #显示回车符 (\ r), specific in the VIM environment will be displayed as "^m" symbol: Set list #显示换行符 (\ n), the specific re-vim environment appears as "$" symbol. This command also displays tabs, which appear as "^i" symbols in the VIM environment




Remove the carriage return so that the shell script can function correctly

:%s/\r//g


Shell foot This report wrong line break syntax error near unexpected token \ r

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.