syntax error: unexpected end of file
在windows上写的shell文件 上传到linux服务器老是报 syntax error: unexpected end of file 一行行删除检查也没找到原因 ,网上一搜才发现:
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
结案
转载于:https://www.cnblogs.com/wangxusummer/p/4030410.html
syntax error: unexpected end of file相关推荐
- .bashrc: line 123: syntax error: unexpected end of file
今天在Ubuntu上面配置Java环境,使用下面指令进入之后,好像对文件进行了修改. sudo vim ~/.bashrc 使用 source ~/.bashrc 报错如下: bash: .bashr ...
- shell:syntax error:unexpected end of file/Starting proxy www-balancer: cannot bind socket--转载
src:http://www.2cto.com/os/201308/238962.html 执行某bash脚本是发生: syntax error: unexpected end of file 主要问 ...
- SHELL脚本“syntax error: unexpected end of file”解决方案[半原创]
SHELL脚本"syntax error: unexpected end of file"解决方案[半原创] 参考文章: (1)SHELL脚本"syntax error: ...
- 执行shell脚本报错:syntax error near unexpected token `或syntax error: unexpected end of file...
引起此问题最可能的原因是: 在windows下编写的文件上传到linux执行. 我是在notepad++上编写的代码,之后上传到linux执行,报此错误.仔细检查,语法方面没有错误.上网查了一下,发现 ...
- 脚本执行报错 syntax error: unexpected end of file
发生场景:windows环境编辑/生成的shell脚本,在linux系统上运行时报错 可能的原因和解决办法: 1.如果脚本里面有if这样的,先数一下if 和 fi的数量是否匹配,很多时候是漏写了fi ...
- Parse error: syntax error, unexpected end of file in the line
Parse error: syntax error, unexpected end of file in the line <?php if($member['user']){echo $mem ...
- [Vim 编译出错]syntax error: unexpected end of file
系统环境:OSX 编辑器:vim 问题说明:编译文件时出现"Syntax error:unexpected end of file"错误 从网页粘贴到vi里的配置代码env.sh, ...
- SHELL syntax error:unexpected end of file 提示错误
解决方案: 使用下面的命令将文件格式设置为unix格式即可解决上述错误. vi M.txt :set fileformat=unix :wq 参考文档: http://hi.baidu.com/haj ...
- PHP问题 —— PHP Parse error: syntax error, unexpected
1.1 PHP Parse error: syntax error, unexpected end of file 1.1.1 现象 网上下载了一些PHP代码,运行时报错:6.18 PHP P ...
最新文章
- mysql临时表如何分页查询慢_数据量很大,分页查询很慢,怎么优化?
- SpringCloud-容错处理Hystrix熔断器
- Shell中常用的系统函数basename和dirname
- ruby scala python_解释一个基准在C,Clojure,Python,Ruby,Scala和其他
- 嵌入式Linux入门9:Linux系统使用
- Spark SQL join的三种实现方式
- Exchange Server 2016 独立部署/共存部署 (五)—— 配置DAG(下)
- LAMP下http跳转到 https
- 游戏设计规则探秘之宾语
- C# datagridview列绑定类中类的属性
- C4droid导出程序
- 5次Shift破解Win7登录密码
- (转)高盛报告:人工智能、机器学习和数据将推动未来生产力的发展
- 第三方、第四方扫二维码的支付平台有哪些?
- 修复损坏的gz或tar.gz压缩文件之方法篇
- python中的path的使用
- .Net Core 源码解析
- Python+Excel随机试卷及答案生成程序
- Linux:CentOS6.8突然卡死,CPU使用率突然暴涨后恢复正常
- 有限元网格生成程序及软件