首页 > 系统服务 > 详细

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

时间:2014-03-29 20:56:05      阅读:788      评论:0      收藏:0      [点我收藏+]

 

文章出处: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

原文:http://www.cnblogs.com/tiny-kong/p/3632357.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!