参考:-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