If you print the execution result to a file, you will surely think of the output redirection character> or>, but the output redirection can only be output to the file or screen, and cannot be output at the same time. now we have the tee tool.
Simply put, the file display command ls
Root @ ubuntu :~ /Test_dis # ls | tee log_filelog_filereadmeuploadutilities
Execute Command
Ls | tee log_file
When ls is executed, use the MPs queue to send the content to tee for processing. Then, tee outputs the ls execution results to the screen and then outputs the results to the log_file file. If log_file does not exist, it is created and overwritten,
If you want to add the end of the file to log_file rather than overwrite it, you can add the-a parameter.
Ls | tee-a log_file
This will not overwrite the log_file.
This tool is linux. If you want to use it on windows, you need to install PowerShell.
Reference:
Http://en.wikipedia.org/wiki/Tee_ (command)
Http://codingstandards.iteye.com/blog/833695
Http://www.linuxidc.com/Linux/2006-09/124.htm
-------------------------------------------------
Http://superuser.com/questions/74127/tee-for-windows