We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/bin/bash^M: bad interpreter: No such file or directory
执行xxx.sh时,提示/bin/bash^M: bad interpreter: No such file or directory,打开文件显示正常
xxx.sh
出现上面错误的原因之一是脚本文件是DOS格式的,即每一行的行尾以\r\n来标识,我这里是因为在 macOS 上运行 Windows 下git clone的代码库里的脚本
\r\n
git clone
使用dos2unix命令
dos2unix
macOS上安装brew install dos2unix
brew install dos2unix
然后对对应文件执行dos2unix xxx.sh即可
dos2unix xxx.sh
递归将某个目录下所有文件转换:find . -type f -print0 | xargs -0 dos2unix
find . -type f -print0 | xargs -0 dos2unix
递归将某个目录下所有以.sh结尾的文件转换:find . -name "*.sh" -print0 | xargs -0 dos2unix
.sh
find . -name "*.sh" -print0 | xargs -0 dos2unix
https://blog.csdn.net/kwu_ganymede/article/details/54134104
https://stackoverflow.com/questions/11929461/how-can-i-run-dos2unix-on-an-entire-directory
The text was updated successfully, but these errors were encountered:
No branches or pull requests
/bin/bash^M: bad interpreter: No such file or directory
问题解决方案问题描述
执行
xxx.sh
时,提示/bin/bash^M: bad interpreter: No such file or directory
,打开文件显示正常问题原因
出现上面错误的原因之一是脚本文件是DOS格式的,即每一行的行尾以
\r\n
来标识,我这里是因为在 macOS 上运行 Windows 下git clone
的代码库里的脚本解决方案
使用
dos2unix
命令macOS上安装
brew install dos2unix
然后对对应文件执行
dos2unix xxx.sh
即可递归将某个目录下所有文件转换:
find . -type f -print0 | xargs -0 dos2unix
递归将某个目录下所有以
.sh
结尾的文件转换:find . -name "*.sh" -print0 | xargs -0 dos2unix
参考资料
https://blog.csdn.net/kwu_ganymede/article/details/54134104
https://stackoverflow.com/questions/11929461/how-can-i-run-dos2unix-on-an-entire-directory
The text was updated successfully, but these errors were encountered: