Solution to No such file or directory prompt in Linux

Note:
Under linux, when ./xxx.sh executes the shell script, it will prompt No such file or directory. But the shell obviously exists, why is it prompted?

Solution to No such file or directory prompt in Linux


This is actually because the encoding method is wrong. For example, if you edit sh under win, then copy it directly to linux

Implementation:
There are 2 ways to go about this.
1) Conversion under Windows:
Use some editors such as UltraEdit or EditPlus to convert the script code first, and then execute it in Linux. The conversion method is as follows (UltraEdit): File–>Conversions–>DOS->UNIX.

2) Open the sh file with vim, input:
:set ff //press Enter, display fileformat=dos
:set ff=unix //reset the file format
: wq //save and exit and
execute again, it will not prompt No again Such file or directory this problem.

Guess you like

Origin blog.csdn.net/qq_39436397/article/details/132086282