Tag Archives: SHELL Run Error

[Solved] SHELL Run Error: “-BASH: ./TEST.SH: /BIN/BASH^M: BAD INTERPRETER: NO SUCH FILE OR DIRECTORY”

Solve the error reported by the running shell

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

What is the reason? There is reason to suspect that it is a file format problem? We use VIM test.sh to enter the test.sh file, and then execute it in the bottom mode: set FF to check. The result shows that fileformat = DOS. Look, it is indeed a file format problem. How to solve it?

Solution:

[root@admin .sh]# vim test.sh

Execute: e + + FF = UNIX%, then delete the ^ m symbol
save and exit

or:

[root@admin .sh]# sed -i "s/\r//" test.sh

Or:

[root@admin .sh]# dos2unix test.sh

Or: VIM test.sh open the file, execute: set FF = UNIX, set the file to UNIX, then execute: WQ, and save it in UNIX format.