Refer to the blog of the struggling people in Beijing, URL: https://blog.csdn.net/u012453843/article/details/69803244
xx.sh scripts written under Windows, such as notepad++, after being passed on to UNIX or Linux servers, and then run scripts that prompt:
Syntax error:unexpected end of File error
Shell script execution error $ ' \ R ': Command not Found
The reason is: Dos/window press a return key is actually entered is "Enter (CR)" and "line break (LF)", and Linux/unix press the return key once only enter "line break (LF)", so the modified SH file in each line will be a CR, So Linux running under the error can not find the command.
The solution is, first of all, we can look at the current script. The format of SH is dos.
Vim xx.sh, press ESC, Output:: Set FF, and then enter, you can see the current script format is DOS.
We need to change the format to UNIX. The method is: Set Ff=unix or set Fileformat=unix. Then through: Set FF return view.