http://www.tldp.org/LDP/abs/html/io-redirection.html
http://unix.stackexchange.com/questions/20469/difference-between-21-output-log-and-21-tee-output-log (good)
http://linuxcommand.org/lts0060.php
2>&1 >output.log
means first start sending all file handle 2 stuff (standard error) to file handle 1 (standard output) then send that to the file output.log
. In other words, send standard error and standard output to the log file.
2>&1 | tee output.log
is the same with the 2>&1
bit, it combines standard output and standard error on to the standard output stream. It then pipes that through the tee
program which will send its standard input to its standard output (like cat
) and also to the file. So it combines the two streams (error and output), then outputs that to the terminal and the file.
The bottom line is that the first sends stderr
/stdout
to the file, while the second sends it to both the file and standard output (which is probably the terminal unless you're inside another construct which has redirected standard output).
I mention that last possibility because you can have stuff like:
(echo hello | tee xyzzy.txt) >plugh.txt
where nothing ends up on the terminal.
such as :
./.build_release/examples/re_id/re_identity.bin 2>&1 | tee train.log