/bin/bash^M: bad interpreter: No such file or directory 解决办法

参考:-bash: ./my_script: /bin/bash^M: bad interpreter: No such file or directory [duplicate]

有的时候运行.sh文件会莫名其妙报错,报错信息如下:

$ ./scriptname.sh
-bash: ./scriptname.sh: /bin/bash^M: bad interpreter: No such file or directory

解决办法:运行如下命令

$sed -i -e 's/\r$//' scriptname.sh

之后再次运行sh文件即可

$ ./scriptname.sh
posted @ 2018-12-11 16:11  marsggbo  阅读(527)  评论(0编辑  收藏  举报