I have a list of files and my small program called app
. My list is file01.txt
to file1000.txt
. I want to create a bash script that runs one by one:
app -i list01.txt # to the file1000.txt
I want to execute the commands one by one, when the previous command finishes. Am I doing it in the right way in my example?
#!/bin/bash
app -i list01.txt;
app -i list02.txt;
app -i list03.txt;
You can use seq
to generate all the commands:
seq -f 'echo app -i file%02.0f.txt' 1 1000 | sh
If the output looks right, remove the echo
If your app is running in standard foreground CLI (terminal) mode, you are right. This way, everything runs one by one, top to bottom.
Another way to run app2
only after app1
is as follows:
app1 && app2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.