In the local windows, wrote a shell script, using SFTP or other methods to upload the script, execute the script appears no such file or directory prompt, see the script encoding and permissions are no problem, create a new file under Linux, copy the script contents, Content is exactly the same, but can be executed.
Cause: Windows line break symbol is "\ r \ n", and Linux is "\ r" does not "\ \ \", when the shell script is written under Windows, the default all line break is "\ r \ n", Linux is not able to correctly identify the file, will prompt the above error , you can use a third-party editor, such as UltraEdit, to convert the file to UNIX format and execute "File->conversions->dos to Unix", which is to delete the "\ r" symbol.
A simple solution under Linux:
Modified file: sed-i ' s/\r$//g ' filename manually delete ' \ r ' symbol
After Vim opens the file, the command mode executes: Set Ff=unix, then save on the line
Converting files using the Dos2unix command
Scripts uploaded from Windows to Linux cannot be executed