用shell编写的一个脚本,执行的时候报错:syntax error: unexpected end of file!

发生这种报错有两种原因:

第一种:

如果你是用 windows 系统编写的脚本,那么就有可能是 fileformat 类型不同!可能是 fileformat=dos ,那么你需要把格式修改为unix,方法是直接输入 :set ff=unix,输入完成后回车即可看到:
fileformat=unix

第二种:

如果你是用 Linux 系统编写的 shell 脚本,在 vim 的命令模式下,执行 :set ff 就能看到 fileformat 类型是 unix ,那么恭喜你,你的 shell 脚本里存在语法错误,你可以使用二分法逐段检查错误,具体就是注释一部分,留一部分,然后执行 sh -n 脚本名字 来检查错误,知道排查处错误为止!
————————————————
版权声明:本文为CSDN博主「小白网管之路」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_44297303/java/article/details/102956879

syntax error: unexpected end of file完美解决方案的更多相关文章

  1. SHELL syntax error:unexpected end of file 提示错误

    SHELL syntax error:unexpected end of file 提示错误 if [ -n "$1" ] then " else " fi e ...

  2. shell 报错:syntax error: unexpected end of file

    有时执行脚本时会报错: [root@host1 shell]# sh -x test.sh + $'\r' : command not found test.: syntax error: unexp ...

  3. win-Linux文件脚本迁移过程中的问题 syntax error: unexpected end of file

    问题:  在win下写好的shell脚本,放到Linux上测试sh -n报错如下 ORA_check.sh: line 251: syntax error: unexpected end of fil ...

  4. PHP关于syntax error语法错误的问题(Parse error: syntax error, unexpected end of file in xxxxxxxx)

    在php程序出现类似 Parse error: syntax error, unexpected end of file in xxxxxxxx  on line xx 的错误. 如图 如果发现php ...

  5. 【问题解决】syntax error: unexpected end of file或-bash: ./full_build.sh: /bin/bash^M: bad interpreter: No

    在阅读的过程中有不论什么问题,欢迎一起交流 邮箱:1494713801@qq.com    QQ:1494713801 运行一个脚本full_build.sh 时, 一直是提示我: -bash: ./ ...

  6. input01.sh: line 11: warning: here-document at line 4 delimited by end-of-file (wanted `EOF') input01.sh: line 12: syntax error: unexpected end of file

    写了个脚本用cat>>EOF报错如下: input01.sh: line 11: warning: here-document at line 4 delimited by end-of- ...

  7. 报错解决——linux下执行sh出现异常"syntax error: unexpected end of file"

    有时我们在linux下执行一个sh文件,会报错“SYNTAX ERROR:UNEXPECTED END OF FILE”,这个现象主要是工作的系统环境改变造成的. 若最初脚本中是在windows下,使 ...

  8. 解决执行脚本报syntax error: unexpected end of file或syntax error near unexpected token `fi'错误的问题

    参考:https://blog.csdn.net/u012453843/article/details/69803244 解决执行脚本报syntax error: unexpected end of ...

  9. 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 主 ...

随机推荐

  1. golang中使用zap日志库

    1. 快速使用 package main import ( "go.uber.org/zap" "time" ) func main() { // 1. sug ...

  2. 图文并茂理解iptables

    原文地址:http://www.zsythink.net/archives/1199 以下是转载内容: iptables详解:图文并茂理解iptables | 朱双印博客 这篇文章会尽量以通俗易懂的方 ...

  3. 网络分层和TCP三次握手

    它们就是 OSI 的七层模型,和 TCP/IP 的四层 / 五层模型.这两种模型的最大区别,就是前者在传输层和应用层之间,还有会话层和表示层,而后者没有. TCP三次握手: 位码即tcp标志位,有6种 ...

  4. python 小兵(8)闭包和装饰器

    闭包"是什么,以及,更重要的是,写"闭包"有什么用处. (个人理解) 1."闭包"是什么 首先给出闭包函数的必要条件: 闭包函数必须返回一个函数对象 ...

  5. Redis为什么是单线程,高并发快的3大原因详解

    出处知乎:https://zhuanlan.zhihu.com/p/58038188 Redis的高并发和快速原因 1.redis是基于内存的,内存的读写速度非常快: 2.redis是单线程的,省去了 ...

  6. python folium 库学习

    一.简介 folium是js上著名的地理信息可视化库leaflet.js为Python提供的接口,通过它,我们可以通过在Python端编写代码操纵数据,来调用leaflet的相关功能,基于内建的osm ...

  7. 类扩展(Class Extension)

    类扩展(Class Extension) 也有人称为匿名分类 - 作用     - 能为某个类增加额外的属性.成员变量.方法声明     - 一般将类扩展写到.m文件中     - 一般将一些私有的属 ...

  8. 21个实用便利的PHP代码

    转载请注明来源:https://www.cnblogs.com/hookjc/ 1. PHP可阅读随机字符串 此代码将创建一个可阅读的字符串,使其更接近词典中的单词,实用且具有密码验证功能. /*** ...

  9. PHP页面编码问题

    页面编码统一MySQL数据库编码.html页面编码.PHP或html文件本身编码要全部一致.1.MySQL数据库编码:建立数据库时指定编码(如gbk_chinese_ci),建立数据表.建立字段.插入 ...

  10. java创建自定义类的对象数组

      1 public class Student{ 2 static int number = 0; // 静态变量的访问可以不用创建类的实例就可就可使用< 类名.属性 >的方法访问 3 ...