[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: argument precedence, output redirection
From: |
Chet Ramey |
Subject: |
Re: argument precedence, output redirection |
Date: |
Fri, 3 Dec 2010 09:50:08 -0500 |
> 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?
Redirections are processed left-to-right (or, if you prefer, beginning to end).
The manual page has this to say:
Note that the order of redirections is significant. For example, the
command
ls > dirlist 2>&1
directs both standard output and standard error to the file dirlist,
while the command
ls 2>&1 > dirlist
directs only the standard output to file dirlist, because the standard
error was duplicated as standard output before the standard output was
redirected to dirlist.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
- argument precedence, output redirection, Payam Poursaied, 2010/12/03
- Re: argument precedence, output redirection, Greg Wooledge, 2010/12/03
- Re: argument precedence, output redirection, Eric Blake, 2010/12/03
- Re: argument precedence, output redirection,
Chet Ramey <=
- Re: argument precedence, output redirection, Marc Herbert, 2010/12/03