Reputation: 21
I have 36 subdirectories in the same directory named 10,11,12,....45
In each subdirectory there is a file named pressure.sh
that I would like to execute a command on, the command is qsub
I was wondering if there was a way where I could execute the command qsub on each pressure.sh
file in each subdirectory 10-45 from the parent directory?
So I am looking for a code that executes "qsub pressure.sh
" one by one in each subdirectory so I do not have to do it one by one every time.
Any help would be appreciated.
Upvotes: 0
Views: 1058
Reputation: 74028
Another way is with find
and xargs
:
find . -name pressure.sh | xargs -n 1 qsub
which finds all pressure.sh
, even if deeper than one level.
Upvotes: 1
Reputation: 179422
You can use a glob:
for i in */pressure.sh; do
qsub $i
done
To be more explicit about the directories, you can use a range:
for i in {10..45}/pressure.sh
Upvotes: 4