5

I have a bunch of slurm jobs that produce standard output and error files with this format:

<string>.<string>.<string>.<job_id>.ERR

where job_id is the job id assigned by slurm.

So to get these job ids I can:

cut -f 4 -d "." *.ERR

I'd like to pipe the output of this command to a loop that will run sacct -j <job_id> and grep which jobs have failed, using:

sacct -j <job_id> | grep "FAILED"

Can this be done in one command?

1 Answer 1

6

You could use a Bash read loop, with process substitution:

while read -r job_id; do
  sacct -j "$job_id" | grep "FAILED"
done < <(cut -f4 -d. *.ERR)

You could also use xargs, which is more succint:

cut -f4 -d. *.ERR | xargs -n 1 sacct -j | grep "FAILED"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.