The tee command acts the way it is pronounced. It takes the input and sends one copy to the standard output and another copy to a file. If you want to see your output and save it to a file at the same time, then this is the command for you.
The general format is:
tee -a files
where, ‘-a’ means append all output to a file.
Tee comes in handy when you are running commands or scripts and you want to keep a log of the output.
Let’s look at an example. Using the who command, the output is sent to the screen and a copy is sent to a file called who.out.
$ who | tee who.out louise pts/1 May 20 12:58 (22.214.171.124) matthew pts/0 May 20 10:18 (126.96.36.199) cat who.out louise pts/1 May 20 12:58 (188.8.131.52) matthew pts/0 May 20 10:18 (184.108.40.206) ...