Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: wait for the next process to finish
- X-seq: zsh-users 16635
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: wait for the next process to finish
- Date: Tue, 13 Dec 2011 17:45:00 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.fr; s=s1024; t=1323798302; bh=FzLDDQDDLfez9w5jqr2YvZnF5GUjL+gfedaKHWdwetg=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent; b=lkONn+Bi6Wy87jPgbvxWOFB+Ak/FoYTeYwsmCKGO/3sp0eE2Cm8WqHwCFINBdoBy0kmt8U3FDYcUB/0XREb0HvtuA5GVYI5hdl4oBeeU71HHCw0h6qkxDR5CftJE69qMO8KuvJBp/br5UI3sgX9bDGdKYoJ4939uOyRfily/5wo=
- In-reply-to: <20111212154601.GA5198@cosy.cit.nih.gov>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20111212154601.GA5198@cosy.cit.nih.gov>
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