【LINUX】SHELL syntax error:unexpected end of file
2016-12-20 10:20
489 查看
解决思路:
DOS下文件和Linux下文件格式差异问题导致的。
DOS下的文本文件是以\r\n作为断行标志的,表示成十六进制就是0D 0A。而Unix下的文本文件是以\n作为断行标志的,表示成十六进制就是0A。
【在windows里,换行用的两个符号,回车\r,换行符号\n,在linux下只需一个符号\n就可以了.】
DOS格式的文本文件在Linux下,用较低版本的vi打开时行尾会显示^M,当然也有可能看不到,但是在vi的时候,会在下面显示此文件的格式,"M.txt" [dos] 8L, 72C表示是一个dos文件格式。
解决方案:
使用下面的命令将文件格式设置为unix格式即可解决上述错误。
vi M.txt
:set fileformat=unix
:wq
DOS下文件和Linux下文件格式差异问题导致的。
DOS下的文本文件是以\r\n作为断行标志的,表示成十六进制就是0D 0A。而Unix下的文本文件是以\n作为断行标志的,表示成十六进制就是0A。
【在windows里,换行用的两个符号,回车\r,换行符号\n,在linux下只需一个符号\n就可以了.】
DOS格式的文本文件在Linux下,用较低版本的vi打开时行尾会显示^M,当然也有可能看不到,但是在vi的时候,会在下面显示此文件的格式,"M.txt" [dos] 8L, 72C表示是一个dos文件格式。
解决方案:
使用下面的命令将文件格式设置为unix格式即可解决上述错误。
vi M.txt
:set fileformat=unix
:wq
相关文章推荐
- linux-shell syntax error: unexpected end of file
- 【Linux】Shell脚本“syntax error: unexpected end of file”原因及处理
- SHELL syntax error:unexpected end of file 提示错误; windows下修改linux文件导致linux文件无法使用
- 解决shell错误:syntax error: unexpected end of file
- shell脚本调试报错:"syntax error: unexpected end of file"
- shell错误一例 syntax error: unexpected end of file
- Shelll 错误 syntax error: unexpected end of file
- Shell中EOF出现syntax error: unexpected end of file
- shell中出现syntax error: unexpected end of file
- linux下执行sh出现异常"syntax error: unexpected end of file"
- SHELL syntax error:unexpected end of file 提示错误
- 解决shell错误:syntax error: unexpected end of file
- shell syntax error: unexpected end of file
- SHELL syntax error:unexpected end of file 提示错误
- shell中出现syntax error: unexpected end of file
- syntax error: unexpected end of file windows linux换行 文件格式
- linux脚本相关: Syntax error: end of file unexpected (expecting "then") 提示错误
- shell入门的拦路虎:syntax error: unexpected end of file
- shell:syntax error:unexpected end of file/Starting proxy www-balancer: cannot bind socket--转载
- Shell脚本:“syntax error:unexpected end of file”