In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
What if linux can't find the file when executing the script? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
When executing an existing shell script file on Linux, it prompts you that the file does not exist.
The general reason at this time is that the system in which your shell script is written is not consistent with the system in which you execute the script. For example, when you write a script in window system, you will encounter this problem when you copy it to Linux system. The reason is that .sh files edited under windows are in dos format, while linux can only execute scripts in unix format.
Because pressing the enter key once under dos/window is actually entering "enter (CR)" and "line feed (LF)", while pressing the enter key once under Linux/unix only enters "line feed (LF)", the modified sh file will have an extra CR on each line, so the command will not be found in error when running under Linux.
In addition, this problem may also occur when you download the shell script file in the source file on github using the windows system, and when you extract it and copy it to the Linux system for execution.
Solution:
We can view the format format of the file through the vi editor. The steps are as follows:
1. First open the file with the vi command
[root@localhost test] # vi test.sh
two。 Use the: set ff command in vi command mode
You can see that the format of the file is
Fileformat=dos
3. Modify the file format to unix
Use vi/vim to modify the file format
Command:: set ff=unix
Or: set fileformat=unix
Then: wq saves and exits and re-executes the script.
On the linux script execution can not find the file how to solve the problem shared here, I hope the above content can be of some help to you, if you still have a lot of doubts unsolved, you can follow the industry information channel to learn more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 222
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.