Under Linux execute the SH script written under Windows __linux

Source: Internet
Author: User

Refer to the blog of the struggling people in Beijing, URL: https://blog.csdn.net/u012453843/article/details/69803244

xx.sh scripts written under Windows, such as notepad++, after being passed on to UNIX or Linux servers, and then run scripts that prompt:

Syntax error:unexpected end of File error

Shell script execution error $ ' \ R ': Command not Found


The reason is: Dos/window press a return key is actually entered is "Enter (CR)" and "line break (LF)", and Linux/unix press the return key once only enter "line break (LF)", so the modified SH file in each line will be a CR, So Linux running under the error can not find the command.


The solution is, first of all, we can look at the current script. The format of SH is dos.

Vim xx.sh, press ESC, Output:: Set FF, and then enter, you can see the current script format is DOS.

We need to change the format to UNIX. The method is: Set Ff=unix or set Fileformat=unix. Then through: Set FF return view.



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.