O padrão POSIX especifica que o redirecionamento de shell é da esquerda para a direita; ou seja, a ordem é significativa:
The construct
2>&1is often used to redirect standard error to the same file as standard output. Since the redirections take place beginning to end, the order of redirections is significant. For example:ls > foo 2>&1directs both standard output and standard error to file
foo. However:ls 2>&1 > fooonly directs standard output to file
foobecause standard error was duplicated as standard output before standard output was directed to filefoo.
bash opera em conformidade com esta parte da norma:
$ ls doesnotexist > foo 2>&1
$ cat foo
ls: cannot access doesnotexist: No such file or directory
$ ls doesnotexist 2>&1 > foo
ls: cannot access doesnotexist: No such file or directory
$ cat foo
$
Quanto à tubulação:
Because pipeline assignment of standard input or standard output or both takes place before redirection, it can be modified by redirection. For example:
$ command1 2>&1 | command2sends both the standard output and standard error of
command1to the standard input ofcommand2.