Linux执行脚本出现/bin/bash^M: bad interpreter: No such file or directory

在windows系统下用notepad++编辑器编写了一段代码保存为shell.sh,直接上传到了linux系统中,赋予可执行权限:chmod +x shell.sh,然后执行./shell.sh却提示/bin/bash^M: bad interpreter: No such file or directory

造成这个问题的原因是:windows下的编码格式与linux下不同

解决方法,在linux下使用dos2unix工具转码一下即可,centos系统只需要yum -y install dos2unix就可以安装完成,然后用dos2unix shell.sh完成编码转换,然后就可以快乐地执行了!

上一篇: 下载谷歌浏览器(Chrome)扩展离线安装包crx文件
下一篇: windows下批处理设置IP地址

发表评论