原由
在 windows 编写的 shell 文件 复制到 centos 下无法运行
其主要原因是文件编码不对
解决
- 使用vi工具
vi test.sh - 利用如下命令查看文件格式
:set ff或:set fileformat - 可以看到如下信息
fileformat=dos或fileformat=unix - 利用如下命令修改文件格式
:set ff=unix或:set fileformat=unix :wq(存盘退出)
其他
使用 dostounix 一劳永逸
在 windows 编写的 shell 文件 复制到 centos 下无法运行
其主要原因是文件编码不对
vi test.sh:set ff 或 :set fileformat fileformat=dos 或 fileformat=unix :set ff=unix 或 :set fileformat=unix :wq (存盘退出)使用 dostounix 一劳永逸