[vox-tech] quick, stupid bash question

Shawn P. Neugebauer vox-tech@lists.lugod.org
Wed, 29 May 2002 12:00:20 -0700


On Wednesday 29 May 2002 11:29 am, you wrote:
> begin nbs <nbs@sonic.net>
> > On Wed, May 29, 2002 at 11:11:19AM -0700, Peter Jay Salzman wrote:
> > > this redirects stderr to stdout and pipes the whole thing to grep:
> > >    strace lsof 2>&1 | grep System
> > Try something like:
> >      strace lsof 2>&1 1> /dev/null | grep
>
> ok, haven't tried this, but this looks to me like:
>
> put stderr into stdout
> redirect stdout (and therefore stderr) into /dev/null
> pipe stdout (which should be null) to grep.
>
> yet it works.  where is my thinking going wrong?

here's my reading of the man page.  redirects are
processed L->R.  "2>&1" *duplicates* the stdout file
descriptor and sends stderr there.  then stdout 
(the original) is redirected to /dev/null.  so this is what 
you needed.  reversing the order sends stdout to 
/dev/null, *then* duplicates the stdout file descriptor
and sends stderr there, so it too ends up in /dev/null.
not what you wanted.

shawn.