syntax error: unexpected end of file 不一定是因为有特殊字符
来源:互联网 发布:替身绫辻行人 知乎 编辑:程序博客网 时间:2024/05/05 10:44
通常情况是这样,但是这次遇到不是因为\R\N。
if [ -n "$1" ]
then
echo "111"
else
echo "222"
fi
exit 0
执行sh my.sh par 提示syntax error:unexpected end of file.错误请问为什么啊?
文本编辑是在windows下通过记事本编写的这个文件,运行 在cygwin模拟LINUX软件环境下。
解决思路:
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
------------------------------------------这次的情况------------------
if [ -n "$1" ]
then
echo "111"
else
echo "222"
if --------------------------这个单词写反了,改对就好了。。。。
exit 0
0 0
- syntax error: unexpected end of file 不一定是因为有特殊字符
- syntax error: unexpected end of file
- syntax error: unexpected end of file
- shell:syntax error:unexpected end of file
- syntax error: unexpected end of file解决方法
- syntax error:unexpected end of file
- syntax error: unexpected end of file
- syntax error, unexpected end of file
- Parse error: syntax error, unexpected end of file in
- Parse error: syntax error, unexpected end of file
- SHELL syntax error:unexpected end of file 提示错误
- Shelll 错误 syntax error: unexpected end of file
- Shelll 错误 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
- liunx下syntax error: unexpected end of file错误提示
- SHELL syntax error:unexpected end of file 提示错误
- 读书笔记:"算法导论"之RANDOMIZED-SELECT(快速选择算法)
- BindProvider
- IOS 3D UI --- CALayer的transform扩展
- c++参数解析类
- Quartz任务调度 时间设置
- syntax error: unexpected end of file 不一定是因为有特殊字符
- Android NFC 标签分发系统小析
- AIDL
- Android触摸事件分发机制
- 【java】递归求数组中的最大值
- 全面了解PPP Multilink
- java 中遍历Map的几种方法
- android BitmapFactory.decodeFile()返回为null问题
- android事件博客