运行脚本时出现了这样一个错误,打开之后并没有找到所谓的^M,查了之后才知道原来是文件格式的问题,也就是linux和windows之间的不完全兼容,解决的方法有两种:
1 如果os中已经安装dos2unix(如果是mac 则是mac2unix)则直接执行该命令
dos2unix adosformatfile.doc
or
mac2unix amacformatfile.doc
如果os未安装可以考虑快速在线安装
yum install dos2unix(centos)
apt-get install dos2unix (ubuntu)
...
2 手动修改
vim test.sh
:set ff?
fileforma=dos|unix
:set fileformat=unix
:wq