Reputation: 13
let's consider a following snippet:
for ((i = 1 ; i <= $N ; i++)); do
sleep 1000 &
done
How to wait for end of at least one subprocess? And then, exit all of them. Is it possible?
Upvotes: 0
Views: 73
Reputation: 242403
Use wait -n
to wait for at least one job to finish.
To kill all the remaining jobs, you can use
jobs -p | xargs kill
Upvotes: 2