man.lsPlain-English help for Unix commands

tee Copy input to a file and to the screen

Reads standard input and writes it to standard output and to one or more files at the same time. Use it to save the output of a command without losing sight of it, or to save a result partway along a pipeline.

Synopsis

COMMAND | tee [-ai] FILE...
COMMAND | tee -a FILE

Common options

Option or formWhat it does
-aAppend to the file instead of overwriting it
-iIgnore the interrupt signal (Ctrl-C), so tee finishes writing
FILE...Not a flag. One or more files to write to. Several files get identical copies

Examples

Show output and save it too
echo hello | tee out.txt
hello
Add a line to the end of a file
echo again | tee -a out.txt
again
Save an intermediate result and keep the pipeline going
sort words.txt | tee sorted.txt | uniq
apple
fig
pear
Write the same output to two files
ls docs | tee one.txt two.txt
old
readme.md
Capture errors as well as normal output
ls missing.txt notes.txt 2>&1 | tee result.txt
Write to a file that needs root
echo '127.0.0.1 test.local' | sudo tee -a /etc/hosts

Notes

See also

Last reviewed 2026-10-07.