8、windows 编写的shell脚本复制到Linux环境下运行

windows 编写的shell脚本复制到Linux环境下运行会报错

原因:

在windows下编写shell脚本回车符是 ,而linux下的回车符是 ,所以在linux下运行脚本的时候,需要修改下脚本的的编码格式。

解决:

(1)使用以下命令查看文本格式:

:set ff

fileformat=dos 或 fileformat=unix

(2)修改文件格式:

:set ff=unix 或 :set fileformat=unix

原文地址:https://www.cnblogs.com/whxiao/p/13433048.html