网站首页 文章专栏 syntax error near unexpected token `$’do\r”

syntax error near unexpected token `$’do\r”

编辑时间:2018-06-26 11:18:10 作者:苹果 浏览量:2284




在windows下通过记事本编辑shell脚本,上传到linux环境下执行。 

提示syntax error:unexpected end of file 或者syntax error near unexpected token `$’do\r”错误


原因:Linux和windows下的回车换行符不兼容的问题


解决方案:

使用下面的命令将文件格式设置为unix格式即可解决上述错误。

vi 1.sh
:set fileformat=unix
:wq



    出自:何冰华个人网站

    地址:https://www.hebinghua.com/

    转载请注明出处


来说两句吧
最新评论