From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22604 invoked from network); 18 Dec 2003 02:13:18 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 18 Dec 2003 02:13:18 -0000 Received: (qmail 514 invoked by alias); 18 Dec 2003 02:13:01 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6919 Received: (qmail 504 invoked from network); 18 Dec 2003 02:13:01 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 18 Dec 2003 02:13:01 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [199.67.51.101] by sunsite.dk (MessageWall 1.0.8) with SMTP; 18 Dec 2003 2:13:1 -0000 Received: (from dan@localhost) by dan.emsphone.com (8.12.10/8.12.10) id hBI2D0WV092545 for zsh-users@sunsite.dk; Wed, 17 Dec 2003 20:13:00 -0600 (CST) (envelope-from dan) Date: Wed, 17 Dec 2003 20:13:00 -0600 From: Dan Nelson To: ZSH User List Subject: Re: how to pipe to stdout and stderr Message-ID: <20031218021259.GE81800@dan.emsphone.com> References: <20031218001201.GA27866@spiegl.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031218001201.GA27866@spiegl.de> X-OS: FreeBSD 5.2-BETA X-message-flag: Outlook Error User-Agent: Mutt/1.5.5.1i In the last episode (Dec 18), Andy Spiegl said: > Maybe I'm just too tired right now, but I can't find the solution how to > pipe the standard output and standard error to 2 different programs. > > Example: > program foo (prints to stdout and stderr) > program bar1 should receive only stdout > program bar2 should receive only stderr > > How can I do this? Someone knows how to do that in bash, too? It's a little tricky since regular pipes are linear. Zsh does let you redirect to commands though: % ( echo stdout ; echo 1>&2 stderr ) > >(tr a-z A-Z) 2> >(tr a-z b-za) tuefss STDOUT % See the zsh manpage, under the heading "PROCESS SUBSTITUTION". -- Dan Nelson dnelson@allantgroup.com