unexpected end of file,设置fileformat即可
来源:互联网 发布:一号店和天猫超市 知乎 编辑:程序博客网 时间:2024/04/29 21:29
Linus 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”。
----------------------------------------------------------------------------
这个问题解决方案如下:学shell还是用vi或vim吧!
----------------------------------------------------------------------------
syntax error: unexpected end of file问题的解决办法
dos文件转换成unix文件格式
dos格式文件传输到unix系统时,会在每行的结尾多一个^M,当然也有可能看不到,但是在vi的时候,会在下面显示此文件的格式,比如 "dos.txt" [dos] 120L, 2532C字样,表示是一个[dos]格式文件,如果是MAC系统的,会显示[MAC],因为文件格式的原因有时会导致我们的unix程序,或者shell程序出现错误,那么需要把这些dos文件格式转换成unix格式,方法是
vi dos.txt
:set fileformat=unix
:w
这样文件就转换成unix格式文件了,一般在windows机器上编写好了文件传到unix下就可能会出现这样的情况,而一般我们使用ftp命令,常常会加上bin参数表示二进制传输,可是试一下不加bin参数,可能传到unix下就是unix格式
在win环境下用editplus将bash文件转为unix文件再上传即可,方法:
1. editplus 2.12 中文版 下,选菜单“格式”--“文件格式” -- “Unix”
2. editplus 3.12 英文版下,选菜单 “Document”-- “File Format(CR/LF)” -- “Change File Format...”-- “UNIX”-- “OK”
其它版本或其它软件的话自己对照吧,记事本是没这选项的 在VI的命令模式下输入“:set nu”
或修改vi设置文件“vi ~/.vimrc”,在其中添加“set nu”
在VI的命令模式下输入“:set nu”,就有行号了。
不过想将这个设置写进VI的设置文件,就
# vi ~/.vimrc
在这个文件中,添加
set nu
就行了。
- unexpected end of file,设置fileformat即可
- unexpected end of file
- unexpected end of file found
- bash: unexpected end of file
- unexpected end of file found
- Linux unexpected end of file ,`xxxx' unexpected
- fatal error C1010: unexpected end of file
- syntax error: unexpected end of file
- syntax error: unexpected end of file
- shell:syntax error:unexpected end of file
- 【原创】gzip: stdin:unexpected end of file
- syntax error: unexpected end of file解决方法
- unexpected end of file found in comment
- unexpected end of file found in comment
- syntax error:unexpected end of file
- gzip: stdin:unexpected end of file
- gzip: stdin: unexpected end of file tar
- gzip: stdin: unexpected end of file 错误
- Uva-1515-Pool construction
- Linux安装MySQL
- cocos2d-x-lua基础系列教程五(lua单例)
- 变量、常量和函数
- STM32基本定时器
- unexpected end of file,设置fileformat即可
- iOS开发UITableView 之代码自定义cell的步骤
- XFire WebService开发快速起步
- 有效防忽悠!5个笔记本选购陷阱
- OCP 1Z0 052 173
- cocos2d-x-lua基础系列教程六(lua-table增删改查)
- Spring集成XFire开发WebService
- DiskSim的安装过程(一)
- 看到一篇很有感触的文章,转载过来,希望更多的技术开发人员能有所得 ----五年软件开发的一点自我总结