On Sun, Apr 14, 2002 at 10:48:43AM -0700, Wolfgang Pfeiffer wrote:
> Hi,
> and thanks for your fast responses :)

> --- [EMAIL PROTECTED] wrote:
> > On Sun, 14 Apr 2002, Wolfgang Pfeiffer wrote:

> > > But could someone explain in human understandable words, what
> > > this part exactly means?

> > It redirects both "stdout" (standard out) and "stderr" (standard error) to 
> > the file /dev/null which is "never never land".

> I don't see the connector between '> /dev/null' and '2>&1' ...
> For example:
> cat /dev/null > some_file
> means - if I understood it correctly -  that the system reads
> '/dev/null' and writes it to 'some_file' with a little help
> from '>', which I call here the connector between both
> parts of them. --- But what is the connection between 
> /dev/null' and '2>&1'

        Yeah, you got two answers that were the same and both were
correction and neither gave you the details or really answered your
question...  Ok...  Let me give it a try...

        ...  > /dev/null 2>&1

        Means, literally...

        Redirect stdout (File Descriptor (fd) #1) to /dev/null  [ > /dev/null ]
                = THEN =
        Redirect stderr (File Descriptor (fd) #2) to fd #1      [ 2>&1 ]

        The 2>&1 construct maps file descriptor #2 [ 2> ] over file descriptor
number 1 [ &1 ] so that were ever file descriptor #1 is being directed
to, that where file descriptor #2 output will also be directed (/dev/null
in this case).  It can be generalized...  n> means redirect fd #n.  It
can be redirected to a file or to another file descriptor.  &m is then the
notation for the file descriptor which is the target of the redirection.
So 2>&1 dumps the output on file descriptor 2 onto file descriptor 1.
0 is stdin, 1 is stdout, 2 is stderr, and you can use higher descriptors
if your application understands them (useful in perl scripts).

        Note, however, that this is a mapping and that order is important!

        "2>&1 > /dev/null"  will map the stderr to what stdout USE TO BE, then
map stdout to /dev/null.  That probably won't do what you want and certainly
does NOT do what's above (unless stdout was aleady directed to /dev/null).

> Thanks in anticipation
> Wolfgang

        Mike
-- 
 Michael H. Warfield    |  (770) 985-6132   |  [EMAIL PROTECTED]
  /\/\|=mhw=|\/\/       |  (678) 463-0932   |  http://www.wittsend.com/mhw/
  NIC whois:  MHW9      |  An optimist believes we live in the best of all
 PGP Key: 0xDF1DD471    |  possible worlds.  A pessimist is sure of it!



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to