HostOnNet Blog

tee linux command

Looking for Linux Server Admin or WordPress Expert? We can help.

tee is a linux command that allows you to redirect out put of a command to STDOUT (console) and a file. This is helpful when you want to see result of a long running process, also want to save it to a file.

For example, i want to save result of the command

find /home/ -name xmlrpc.php

To to a file and watch it. I can do

find /home/ -name xmlrpc.php > ~/xmlrpc.txt
cat ~/xmlrpc.txt

The problem with the above command is you can only see result after find command finished running. To see the result live, use

find /home/ -name xmlrpc.php | tee ~/xmlrpc.txt

tee command by default overwrite the file. If you want to append the result to a file, use -a option. For example

uptime | tee -a ~/uptime.txt

Posted in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.