I have some directories named say 1, 2, 3, 4 etc. How can I write a bash script to run the command "qsub job.sh" in each of these directories? Right now I individually go to each directory and run the command "qsub job.sh" in the terminal. All the directories already have the script job.sh.
Asked
Active
Viewed 27 times
0
-
1Try `for dir in 1 2 3 4; do ( cd 1; qsub job.sh; ); done`. `( list )` executes the `list` in a subshell. If you want to run all jobs in parallel you can launch your `qsub` command in the background: `( cd 1; qsub job.sh & )` – Renaud Pacalet Apr 10 '22 at 07:18
-
@RenaudPacalet you could make this a proper answer. – yugr Apr 10 '22 at 07:30
-
@yugr I would, if I wasn't so sure that this is a duplicate. – Renaud Pacalet Apr 10 '22 at 08:59