On Sun, 2002-04-14 at 17:03, Wolfgang Pfeiffer wrote:
> 
> Two constructs:
> " > /dev/null 2>&1"
> "2>&1 > /dev/null"
> 
> I understand now: the result of both constructs is the *same*, but 
> you seem to be disagreeing: "That ["2>&1 > /dev/null"] probably 
> won't do what you want and certainly does NOT do what's above 
> [i.e." > /dev/null 2>&1", and I didn't understand the rest of your
> sentence - important? - :] (unless stdout was aleady directed 
> to /dev/null)."

The order of redirections is significant.  Normally, in an interactive
shell, each program you run will have two "standard" output channels:
stdout and stderr.  Both of these channels will be directed to the tty
associated with the interactive shell.  

In the case of the first contruct, stdout is directed to /dev/null,
since that is the first redirection the shell received.  Then, stderr is
directed to the same destination as stdout, which is /dev/null.

In the second case, stderr is directed to the same location as stdout,
which is the tty, because it's the first redirection received.  Then,
stdout is directed to /dev/null.  This operation does not affect stderr,
so it is still directed to the tty.  If the process writes anything to
stderr, then it will appear on the tty.

The result of the two constructs is not the same.  :)

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to