In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to execute the code in batches under Linux. It is very detailed and has a certain reference value. Friends who are interested must finish it!
The method of batch execution of code under Linux. Complex can be written in snakemake definition rules, simple shell can be written directly.
Sample code
What you want to achieve:
1, there are 0-9, 10 folders
2. Go to the folder and execute the run.sh script. Because it takes a long time to run, you want to use nohup run.sh & to put it in the background, and save the running log nohup.out at the same time.
1for I in [0-9] *; # 1
2 do
3 cd $I; # 2
4 nohup run.sh &; # 2
5 cd.. /
6done
Error
Because I used the & symbol in the middle, I entered the background ahead of time and couldn't get into the next loop.
If not &, then it is executed sequentially and cannot be carried out in batches.
1for I in [0-9] *; # 1
2 do
3 cd $I; # 2
4 nohup run.sh; # 2
5 cd.. /
6done
Success Code 1for I in [0-9] *; # 1
2 do
3 cd $I; # 2
4 echo "nohup run.sh &" | bash; # 2
5 cd.. /
6done
Here, nohup one-line command, first print with echo, complete the command nohup run.sh &, and then use | bash to execute the previous command, which will achieve what I want to achieve.
Code written in one line
1for I in [0-9] *; do cd $I; echo "nohup run.sh &" | bash; cd.. /; done
The above is all the contents of the article "how to execute Code in batch under Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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: 0
*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.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.