Wednesday, January 19, 2011

Sending output of a command to file and console

The following unix command prints the logs to the mycommand.log file. But it will not output the text to the Console.

mycommand >> /tmp/mycommand .log


This command sends the output to the console as well as to the mycommand.log file

mycommand 2>&1 | tee -a /tmp/mycommand.log

No comments: