Shell error: Syntax error:unexpected end of File

Source: Internet
Author: User

Tagged with: Expect test shell strong analog Linu display binary com

Sometimes the script is executed with an error:

SH -x test. SH + $'\ r': Command not foundtest. SH Panax Notoginseng file

The reasons may be:

Text editing is a file written in Notepad or another editor under Windows, running under the Cygwin simulation Linux software environment.

Solution Ideas:

DOS file and Linux under the file format differences caused by the problem.

Dos text file is based on \ r \ n As a break mark, expressed as 16 binary is 0D 0 A. The text file under Unix is marked with \ n as a break mark, which means that the 16 binary is 0 a.

"In Windows, two symbols for line break, enter \ r, newline symbol \ n, only one sign \ n on linux ."

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

Solution:

Use the following command to set the file format to UNIX format to resolve the above error.

VI Test. SH : Set FileFormat=unix:wq

Why is the script under Windows editing directly copied to the UNIX system that cannot be run directly?

Linux executes Shell pin this report wrong "syntax error near unexpected token ' in"

Long long ago ..... The old-fashioned telex typewriter uses two characters to start a new line. One character moves the slider back to the first place (called the carriage return, the <CR>,ASCII code is 0D), and the other character moves the paper a line (called a newline, <lf>,ascii code of 0A). After the advent of computers, memory was once very expensive. Some people assume that there is no need to use two characters to denote the end of a line. UNIX developers decide that they can use a character to denote the end of a line, and Linux inherits Unix as well as <LF>. Apple developers have defined <CR>. The guys who developed MS-DOS and Windows decided to follow the old-fashioned <CR><LF>.

Because MS-DOS and windows are carriage return + newline to represent line breaks, so under Linux with Vim to see the code written in the VC under Windows, the "^m" symbol after the end of the line, indicating the character.

Shell error: Syntax error:unexpected end of File

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.