Jonathan Matthews <[EMAIL PROTECTED]> writes:
> Ok - can someone explain the following:
> 
> [EMAIL PROTECTED]:/tmp$ ls
> [EMAIL PROTECTED]:/tmp$ rm abc
> rm: cannot remove `abc': No such file or directory
> [EMAIL PROTECTED]:/tmp$ rm abc 2>err

(You could also 'rm abc 2>/dev/null', if you just wanted to discard
stderr.)

> [EMAIL PROTECTED]:/tmp$ cat err
> rm: cannot remove `abc': No such file or directory
> [EMAIL PROTECTED]:/tmp$ rm err
> [EMAIL PROTECTED]:/tmp$ rm abc 2>&1 > err
> rm: cannot remove `abc': No such file or directory
> [EMAIL PROTECTED]:/tmp$ rm abc 2>&1 > /dev/null
> rm: cannot remove `abc': No such file or directory

Redirections are handled left-to-right:

  rm abc       1->(stdout)   2->(stderr)
   2>&1        1->(stdout)   2->(stdout)
   >/dev/null  1->/dev/null  2->(stdout)

with the result being that error messages are printed to wherever
stdout went before, and stdout is discarded.  Instead, you might try

  rm abc >/dev/null 2>&1

-- 
David Maze         [EMAIL PROTECTED]      http://people.debian.org/~dmaze/
"Theoretical politics is interesting.  Politicking should be illegal."
        -- Abra Mitchell

Reply via email to