PDA

View Full Version : bash script



abraxas334
August 31st, 2011, 06:15 PM
I have a set of files called t1.sh t2.sh t3.sh...etc
they are submission scripts to a cluster
so i would submit one as qsub t1.sh
now i want some kind of for loop that does it for all of them in one go. How does that work?

Thanks

Smart Viking
August 31st, 2011, 06:22 PM
Something like this maybe:

for i in {1..100}; do echo qsub\ t$i.sh; done

abraxas334
August 31st, 2011, 06:28 PM
echo just prints it to the screen, but doesn't actually execute this command.

Habitual
August 31st, 2011, 06:36 PM
use

for i in {1..100}; do qsub\ t$i.sh; done

for the real run of the commands.

Smart Viking
August 31st, 2011, 07:00 PM
The reason I used echo, is because you should never trust too much in your own knowledge. So if there were eventual errors or mistakes, they would be caught before any harm was done. I've never heard about the qsub program, so I figured it's best to be on the safe side.