SHELL syntax error:unexpected end of file hint error

Source: Internet
Author: User

If [-N ' $]
Then
echo "111"
Else
echo "222"
Fi
Exit 0

Execute SH my.sh par hint syntax error:unexpected end of file. Error excuse me.

Text editing is a file written by Notepad under Windows, running under the Cygwin simulation Linux software environment.

Solution Idea:

Dos under File and Linux file format differences caused by the problem.

Dos text file is the "R \ n" as the symbol of the break, said 16 into the system is 0D 0 A. The text file under Unix is called \ n as the break mark, which is represented as 16 in 0 a.

"In Windows, two symbols for line wrapping, carriage return \ r, newline symbol \ n, only one symbol in Linux is OK."

DOS format text files in Linux, with a lower version of the vi open at the end will show ^m, of course, may not see, but in VI, will be shown below the format of this file, "M.txt" [dos] 8L, 72C is a DOS file format.

Solution:

You can resolve the above error by using the following command to format the file as UNIX.
VI M.txt
: Set Fileformat=unix
: Wq

Reference Documentation:

Http://hi.baidu.com/hajj1987/blog/item/23339d314e163b275bb5f5ad.html


Section:

Http://wenku.baidu.com/view/4c1e950703d8ce2f00662398.html


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.