Friday, November 13, 2009

Shell Standard I/O

Q: What is the difference between these two shell statements?

$cmd >> $logFile 2>&1
And
$cmd 2>&1 >> $logFile

Answer:
The first one is right and second one is wrong.

first one redirects any output from the $cmd to the $logFile. The second one just redirects the output and not the STDERR to the $logFile.

Reference:
http://www.linux-mag.com/id/5103

No comments:

Post a Comment