linux - When executing a shell script, it prompts "No such file or directory"?
習慣沉默2017-05-16 13:32:13
0
5
1142
1. Transfer the SHELL file written under Windows to Linux for execution, and an error message will appear. 2. Error message: bad interpreter: There is no such file or directory.
There are differences in line breaks and so on in different systems. It should be caused by different invisible characters. Find a conversion tool, or most editors can do this, and just convert some characters.
Does your file path contain Chinese characters? If it contains Chinese characters and your shell script is gbk encoded, the file or directory will not be found, because Chinese file and directory names under Linux are UTF-8 encoded.
There are differences in line breaks and so on in different systems. It should be caused by different invisible characters. Find a conversion tool, or most editors can do this, and just convert some characters.
Screenshots
Errors and codes
Does your file path contain Chinese characters? If it contains Chinese characters and your shell script is gbk encoded, the file or directory will not be found, because Chinese file and directory names under Linux are UTF-8 encoded.
You can consider using the following command to convert the carriage return under Windows to the carriage return under Linux, and try running it again
It always feels like there is no execution permission problem,
Try it
chmod 755 xxx.sh