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

shell 执行报错:

./test.sh: /bin/bash^M: bad interpreter: No such file or directory

 原因:window和linux 的文件格式不同,这个问题是:linux换行只需要 /n windows的换行是 /r/n

导致文件不能识别。

vim 查看文件格式:  

set ff?

fileformat=dos

就是window 的文件格式

修改:

set fileformat=unix

搞定

原文地址:https://www.cnblogs.com/Springmoon-venn/p/7977012.html