bug-bash
[Top][All Lists]
Advanced

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

Re: argument precedence, output redirection


From: Marc Herbert
Subject: Re: argument precedence, output redirection
Date: Fri, 03 Dec 2010 16:51:59 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Thunderbird/3.1.6

Le 03/12/2010 14:46, Payam Poursaied a écrit :
> 
> Hi all,
> I'm not sure this is a bug or please let me know the concept:
> What is the difference between:
> ls  -R /etc/ 2>&1 1>/dev/null
> and
> ls -R /etc/ 1>/dev/null 2>&1
>  
> the second one redirect everything to /dev/null but the first one, still
> prints errors (run as a non root user would unveil the problem)
> it the order of arguments important? If yes, what is the idea/concept behind
> this behavior?

I was confused by this for a long time and kept reading again and
again the correct but *too long* answers others have posted, until I
started using this *short* reading trick:


          2>&1                1>/dev/null

   output2 := output1;      output1 := NULL


When you apply this from left to right it should be quite obvious
why output2 is not NULL.


And now you can finally understand things like this:

exec 3>&1  4>&2        # save
exec 1>/dev/null 2>&1

#  .... discard everything ...

exec 1>&3  2>&4        # restore






reply via email to

[Prev in Thread] Current Thread [Next in Thread]