$‘\r‘: command not found

question

Record the problem of script execution.

Execute the script file in Linux, it prompts:

run.sh: line 1: $'\r': command not found
run.sh: line 2: $'\r': command not found
run.sh: line 3: $'\r': command not found

View checks the run.sh script file and finds no abnormalities. That may be a problem that is invisible to the naked eye.

Examination revealed. There is a newline at the end of the command.
The shell script is written in the Windows system, so the end of the line is: \r\n
and written in the Linux system, it is: \n
so \rjust delete the .

solve

Of course, it is to delete \rcharacter
1, directly delete and make a new copy, provided that the content of the script is relatively small.

touch run.sh
然后复制。

2. Command processing

sed -i 's/\r//' run.sh

3. Command processing

dos2unix run.sh

Then execute the Shell script.

Guess you like

Origin blog.csdn.net/qq_38254635/article/details/131477890