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

Count of a files in a directory and its subdirectpries Unix command

find -type f ¦ wc -l