Linux-en Windows-en

/bin/sh^M: bad interpreter: No such file or directory

bash-logo-small

phenomenon

Create a shell script in Windows, to upload files to the Linux server, I tried to run.
/bin/sh^M: bad interpreter: No such file or directory

An error would come out with.

Cause

Because Windows newline code and Linux line endings are different, but the shell is not executed.

When I check the contents of the file at the cat command, you will find that it contains the "\ r" in the new line code.

solution

You can convert the new line code in sed command.

-Linux-en, Windows-en
-