Re: bash woes
Jonathan Matthews <jaycee@jaycee.uklinux.net> writes:
> Ok - can someone explain the following:
>
> jaycee@kanyon:/tmp$ ls
> jaycee@kanyon:/tmp$ rm abc
> rm: cannot remove `abc': No such file or directory
> jaycee@kanyon:/tmp$ rm abc 2>err
(You could also 'rm abc 2>/dev/null', if you just wanted to discard
stderr.)
> jaycee@kanyon:/tmp$ cat err
> rm: cannot remove `abc': No such file or directory
> jaycee@kanyon:/tmp$ rm err
> jaycee@kanyon:/tmp$ rm abc 2>&1 > err
> rm: cannot remove `abc': No such file or directory
> jaycee@kanyon:/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 dmaze@debian.org http://people.debian.org/~dmaze/
"Theoretical politics is interesting. Politicking should be illegal."
-- Abra Mitchell
Reply to:
- References:
- bash woes
- From: Jonathan Matthews <jaycee@jaycee.uklinux.net>