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

Posted marsggbo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了/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/
$//' scriptname.sh

之后再次运行sh文件即可

$ ./scriptname.sh

以上是关于/bin/bash^M: bad interpreter: No such file or directory 解决办法的主要内容,如果未能解决你的问题,请参考以下文章

/bin/bash^M: bad interpreter: No such file ordirectory

-bash: ./build: /bin/bash^M: bad interpreter: No such file or directory

转:/bin/bash^M: bad interpreter: No such file or directory

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

执行shell脚本错误‘.sh file: /bin/bash^M: bad interpreter’

CentOS6 Shell脚本/bin/bash^M: bad interpreter错误解决方法