tee [OPTION]... [FILE]...
tee copies standard input to each FILE, and also to standard output.
I use this a lot in shell scripts. Often you want to log the output of a script to a file, but also see its output in real time when run manually. This allows that to happen.
Output the results of a command to a file and also the screen
$ ps -ef | tee /tmp/pslist.txt
Append to a previously created output file
$ ps -ef | tee -a /tmp/pslist.txt
Redirect stderr to the file as well
This redirects stderr to the file so that it contains the error message: $ xxx > /tmp/xxx.txt 2>&1 However, when using tee this does not work as expected: $ xxx | tee /tmp/xxx.txt 2>&1 You need to do this: $ xxx 2>&1 | tee /tmp/xxx.txt