Reputation: 6304
I have files with this name format:
<name1>.<name2>.<id>.ERR
where name1
and name2
are character
string
s and id
is a number and all three are unique to each file. (these are standard output files from a slurm
run, and id
is the job id).
I want to find out if these jobs failed so I was thinking of cut
'ing id
from each file name:
ls -1 *.ERR | cut -d "." -f 3
And then pasting "sacct -j "
in front of it.
Is there a one liner that achieves this so that it runs:
sacct -j id
1
sacct -j id
2
.
.
sacct -j id
n
Upvotes: 0
Views: 55
Reputation: 59080
You can simply use xargs
:
ls -1 *.ERR | cut -d "." -f 3 | xargs -L 1 sacct -j
which you can run in parallel with the -P
option to alleviate a bit the latency from interrogating the database.
ls -1 *.ERR | cut -d "." -f 3 | barges -P 4 -L 1 sacct -j
Upvotes: 1
Reputation: 4704
Something like:
for id in $(ls *.ERR | cut -d "." -f 3); do echo "machine: $id"; done
will work, if the files are not a lot (thousands). Replace echo blah blah with sacct -j, like this:
for id in $(ls *.ERR | cut -d "." -f 3); do sacct -j $id; done
There are other ways too.
Upvotes: 1