shell脚本报错:-bash: xxx: /bin/bash^M: bad interpreter: No such file or directory

当我们把文件从windows系统中编辑的文件拷贝到linux系统中,如果我们执行文件会保存如下的错:

shell脚本报错:-bash: xxx: /bin/bash^M: bad interpreter: No such file or directory

1.在命令模式中使用set ff命令查看文件格式

:set ff

可以看到文件的格式为dos:

fileformat=dos

2.通过命令行修改文件格式

:set ff=unix

执行完命令后再次通过set ff命令查看文件格式,可以看到文件的格式为unix:

fileformat=unix
原文地址:https://www.cnblogs.com/zhuzhaoli/p/10796206.html