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

Re: how to pipe to stdout and stderr



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@xxxxxxxxxxxxxxx



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