syntax error near unexpected token 和 Linux Shell syntax error: unexpected end of file

 

文章出处:http://blog.csdn.net/wubai250/article/details/8306718

syntax error near unexpected token `问题的解决

  先说点常识问题:

因为MS-DOS及Windows是回车+换行来表示换行,因此在Linux下用Vim查看在Windows下用VC写的代码,行尾后的“^M”符号,表示的是符。
现在,你使用vim -b 打开你的文件。就会发现每一行都有^M ,那么我们可以是用全局替换替换掉

................解决方法

在命令编辑行<就是: 按ESC键 然后shift+:冒号>输入:%s/^M//g

注意:上述命令行中的“^M”符,不是“^”再加上“M”,而是由“Ctrl+v”、“Ctrl+M”键生成的。

Linux Shell syntax error: unexpected end of file

这种错误都是没有结束标记造得的
如if之后没有fi
for 循环 do之后没有done
while 循环 do这后没有done

在windows上用虚拟机装好redhat linux,完成网络配置,能与我的windows交互了。其它也不需要配。

开始学习bash,每次测试代码都在windows下写好,然后传到linux上执行。

在学习到if等流程控制的语法的时候,我遇见了第一个难题写的if的测试总是不正确:“if.sh: line 11: syntax error: unexpected end of file”。

syntax error near unexpected token 和 Linux Shell syntax error: unexpected end of file,布布扣,bubuko.com

syntax error near unexpected token 和 Linux Shell syntax error: unexpected end of file

上一篇:Booting ARM Linux


下一篇:eclipse 代码分析(1)CopyOnWriteTextStore