help-bash
[Top][All Lists]
Advanced

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

[Help-bash] Redirecting both stdout and stdin to a file


From: Peng Yu
Subject: [Help-bash] Redirecting both stdout and stdin to a file
Date: Sat, 28 Jan 2012 16:15:59 -0600

Hi,

Recent, there were some discussion on I/O redirection. But I still
don't think that I fully understand it. I created the following
example, only the first one can direct both stdout and stdin to a
file. But the second one can not.

To quote recent Chet's email "Redirections are processed left to right
(or, in the Posix parlance, `beginning to end')". What appears to be
in the following example is like from right to left.

There must be some rule that I missed. Could anybody let me know how
to understand the difference between the two commands?

~$ { echo STDOUT; echo STDERR >&2; } > tmp.txt 2>&1
~$ cat tmp.txt
STDOUT
STDERR
~$ { echo STDOUT; echo STDERR >&2; } 2>&1 > tmp.txt
STDERR
~$ cat tmp.txt
STDOUT


-- 
Regards,
Peng



reply via email to

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