help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] stdout and stderr to two different process substitutions


From: Bob Proulx
Subject: Re: [Help-bash] stdout and stderr to two different process substitutions
Date: Wed, 25 Jan 2012 01:52:56 -0700
User-agent: Mutt/1.5.21 (2010-09-15)

Pierre Gaston wrote:
> > Now, I want to tee stderr to a file but I also want to see the stderr
> > output on the screen. Obviously, the following do not work. Could let
> > me know if there is a way to show stderr on the screen as well as
> > saving it to a file? Thanks!
> >
> > prog > >(gzip > xxx.gz) 2> >(tee > yyy.txt)
> >
> One way :
> { prog > >(gzip > xxx.gz) 2> >(tee yyy.txt >&3) ; } 3>&2

That will work.  Good deal.  But the extra redirection through fd 3
and the extra list wrap { ... ;} isn't needed.  Simply redirect to 2
from tee directly and then it is done.

 $ prog > >(gzip > xx.gz) 2> >(tee yy 1>&2)

Test case:
 $ { echo STDOUT ; echo STDERR 1>&2 ;} > >(gzip > xx.gz) 2> >(tee yy 1>&2)

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]