解决: binsh^M: bad interpreter: No such file or directory

    科技2022-07-15  141

    问题

    执行shell脚本遇到异常: /bin/sh^M: bad interpreter: No such file or directory

    原因

    很可能是你在windows下编写的脚本文件,放到Linux中无法识别格式。

    解决方法

    有两种方法:

    用vi打开脚本文件,在命令模式下输入set ff=unix 参考:

    Linux Vim操作

    对需要执行的shell脚本文件执行下面的操作:dos2unix <shell file> 例如: dos2unix test.sh
    Processed: 0.009, SQL: 8