Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: wait for the next process to finish



2011-12-12 10:46:01 -0500, Anthony R Fletcher:
> I just realised that the 'wait' command will either wait for specified
> jobs or all jobs and nothing in between. The manual says "If job is not
> given then all currently active child processes are waited for.".
> 
> So 
> 	sleep 30 &
> 	sleep 10 &
> 	sleep 30 &
> 	sleep 30 &
> 	wait
> waits for all the sleeps to finish.
> 
> How can I wait for just the next job to finish?
[...]

What about:

{
(sleep 4; echo A) &
(sleep 1; echo B) &
(sleep 8; echo C) &
(sleep 2; echo D) &
(sleep 7; echo E) &
(sleep 3; echo F) &
} | while read task; do
  date +"%T: $task finished"
done

17:44:17: B finished
17:44:18: D finished
17:44:19: F finished
17:44:20: A finished
17:44:23: E finished
17:44:24: C finished

-- 
Stephane



Messages sorted by: Reverse Date, Date, Thread, Author