[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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
> 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
> 
> Why can't I silently discard the output of rm?
> Am I missing something subtle?
> Something obvious?
> A vital brain part?

I think on your last couple of tries there you're missing the
precendence of the redirection. You're requesting that standard error
be redirected to standard output *before* you've told the shell to
redirect standard output to /dev/null. So instead of

        rm abc 2>&1 > /dev/null

you need to do

        rm abc > /dev/null 2>&1

That should work.

Gary



Reply to: