tee

tee - read from standard input and write to standard output and files.


Copy standard input to a file and also to standard output:

ping 1.1.1.1 | tee result.txt

Append information to a file:

ping 1.1.1.1 | tee -a result.txt

Write to multiple files:

ping 1.1.1.1 | tee result1.txt result2.txt

Redirect output of one command to another:

cat file.txt | tee result.txt | wc -l

Make tee ignore interrupt:

tail -f /var/log/messages | tee -i result.txt

Display help:

tee --help

Output version information:

tee --version