# 运行命令出现错误 /bin/bash^M: bad interpreter: No such file or directory

**URL:** <https://www.isharkfly.com/t/bin-bash-m-bad-interpreter-no-such-file-or-directory/14568>\
**Category:** DevOps\
**Tags:** linux, wsl\
**Created:** [August 26, 2023, 4:59pm UTC](https://www.isharkfly.com/t/bin-bash-m-bad-interpreter-no-such-file-or-directory/14568 "2023-08-26T16:59:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [August 26, 2023, 4:59pm UTC](https://www.isharkfly.com/t/bin-bash-m-bad-interpreter-no-such-file-or-directory/14568/1 "2023-08-26T16:59:02Z")

</div>

在系统上运行一个 Linux 的命令的时候出现下面的错误信息：

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

![2023-08-26_12-57-00](https://www.isharkfly.com/images/transparent.png)

这个是在 Windows 作为 WSL 的时候出的错误。

## 原因和解决

出现问题的原因在于脚本在 Windows 中使用的回车换行和 Linux 使用的回车换行不一样。

如果你的代码是在 Windows 下被下载的话，那么在 WSL 上运行的时候就有可能会出现上面的问题。

解决办法就是打开 NodePad++ 然后对这脚本文件选择使用 LF 结尾的方式就可以了。

![2023-08-26_12-58-25](https://www.isharkfly.com/images/transparent.png)

目前很多脚本都需要在 Linux 环境下运行，这个也可能是一些公司要求使用 MacOS 的原因吧，因为 MacOS 自带了 Linux，并且没有回车换行的问题。
