syntax error:unexpected end of file

将window上编辑的xxy1.sh脚本上传到linux上,并执行的时候提示

xxy1.sh: line 17: syntax error: unexpected end of file
但是通过cat xxy1.sh查看脚本的时候,未发现语法异常,找了度娘后知道
 
原来是window和linux的文件格式不同导致,解决办法就是
(1)vi xxy1.sh
(2)按下键盘Esc键,按下键盘“:”冒号键
(3)输入:set fileformat=unix,后回车
(4)重复步骤2,输入:wq,后回车
在sh xxy1.sh即可正常执行脚本了
原文地址:https://www.cnblogs.com/xxyBlogs/p/5708170.html