Shell syntax error: unexpected end of file error message
if [ -n "$1" ]then echo "111"else echo "222"fiexit 0
Execute sh my. Sh par and prompt syntax error: unexpected end of file. Why?
Text editing is a file written in notepad in windows and runs in the cygwin simulated Linux environment.
Solution:
This error is caused by the differences in file formats in DOS and Linux.
The text file in DOS uses \ r \ n as the line break Mark, which indicates that the hexadecimal format is 0d 0a. The UNIX text file uses \ n as the line break sign, which indicates that the hexadecimal format is 0a.
In Windows, two line breaks are used: Carriage Return \ r, line feed \ n,In Linux, you only need one \ n symbol..]
In Linux, when a text file in DOS format is opened with a lower version of VI, ^ m is displayed at the end of the line. Of course, it may not be visible, but in VI, the file format is displayed below. "m.txt" [dos] 8l, 72c indicates a DOS file format.
Solution:
Use the following command to set the file format to Unix to solve the preceding error.
vi M.txt:set fileformat=unix:wq
Reference:
Http://hi.baidu.com/hajj1987/blog/item/23339d314e163b275bb5f5ad.html
Section:
Http://wenku.baidu.com/view/4c1e950703d8ce2f00662398.html
Shell syntax error: unexpected end of file error message