^M: bad interpreter: 没有那个文件或目录

简介: linux -bash: ./startup.sh: /bin/sh^M

今天部署项目的时候出现了这样一个错误


linux -bash: ./startup.sh: /bin/sh^M: 坏的解释器: 没有那个文件或目录


仔细看了看脚本并没有什么问题

研究半天发现这个问题大多数是因为脚本文件在windows下编辑过。在windows下,每一行的结尾是\n\r,而在linux下文件的结尾是\n,那么你在windows下编辑过的文件在linux下打开看的时候每一行的结尾就会多出来一个字符\r,用cat -A urfile时你可以看到这个\r字符被显示为^M,这时候只需要删除这个字符就可以了。


可以使用命令 :


sed-i's/\r$//' startup.sh


相关文章
|
3月前
|
移动开发 Shell Linux
百度搜索:蓝易云【Shell错误:/bin/bash^M: bad interpreter: No such file or directory】
将 `your_script.sh`替换为你的脚本文件名。运行此命令后,脚本文件的换行符将被转换为Linux格式,然后就可以在Linux系统上正常执行脚本了。
34 8
|
4月前
|
Python
完美解决丨File “invalid.py“, line 1 print(`Hello World!`) ^ SyntaxError: invalid syntax
完美解决丨File “invalid.py“, line 1 print(`Hello World!`) ^ SyntaxError: invalid syntax
|
5月前
|
Unix Shell iOS开发
Shell错误:/bin/bash^M: bad interpreter: No such file or directory
Shell错误:/bin/bash^M: bad interpreter: No such file or directory
43 0
|
10月前
|
移动开发 Unix Shell
/bin/bash^M: bad interpreter: No such file or directory
/bin/bash^M: bad interpreter: No such file or directory
90 0
|
Shell Linux Windows
-bash usrlocalbindfs binbash^M bad interpreter 没有那个文件或目录
-bash usrlocalbindfs binbash^M bad interpreter 没有那个文件或目录
85 0
|
移动开发 Unix Shell
shell脚本 解决“/bin/bash^M: bad interpreter: No such file or directory”
shell脚本 解决“/bin/bash^M: bad interpreter: No such file or directory”
95 0
成功解决PermissionError: [WinError 5] 拒绝访问 \lib\\site-packages\\h5py\\_errors.cp38-win_amd64.pyd‘
成功解决PermissionError: [WinError 5] 拒绝访问 \lib\\site-packages\\h5py\\_errors.cp38-win_amd64.pyd‘
|
移动开发 Unix Shell
执行shell脚本时提示bad interpreter:No such file or directory的解决办法
执行shell脚本时提示bad interpreter:No such file or directory的解决办法
1050 0
|
Unix Linux Shell
shell解决/bin/bash^M:bad interpreter:No such file or directory
在执行shell脚本时提示这样的错误主要是由于shell脚本文件是dos格式,即每一行结尾以\r\n来标识,而unix格式的文件行尾则以\n来标识。 查看脚本文件是dos格式还是unix格式的几种办法。
2449 0