I have around 100 files.sh
to run by using:
for files in The_job_*;do
sbatch $files;
done
but in one of these 100 files I have 5 that I do not want to be ran, so I would like to say something like:
for files in The_job_*;do
sbatch $files except for "The_job_345", "The_job_567", "The_job_789";
done
Thanks you for your help if you have an idea?
You could use extended glob (have a look at the end of the Pattern Matching section in the reference manual) like so:
shopt -s extglob
for file in The_job_!(345|567|789); do
# Don't forget the quotes:
sbatch "$file"
done
Another possibility is:
# If using bash 3, you'll need to turn extglob on (uncomment the following line)
# shopt -s extglob
for file in The_job_*; do
if [[ $file = The_job_@(345|567|789) ]]; then
continue
fi
sbatch "$file"
done
If you have lots of files to skip, it's probably easier to declare them in an array or an associative array... but since you only have 5, either of the possibilities I gave you should be alright.
Just use an if to guard sbatch
.
for files in The_job_*; do
if ! [[ $files = "The_job_345" || $files = "The_job_567" || $files = "The_job_789" ]]; then
sbatch $files;
fi;
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With