Linux tee command

Updated: 05/04/2019 by Computer Hope
tee command

On Unix-like operating systems, the tee command reads from standard input, and writes to files or standard output.

This page covers the GNU/Linux version of tee.


The tee command is named after the T-splitter in plumbing, which splits water into two directions and is shaped like an uppercase T.

tee copies data from standard input to each FILE, and also to standard output. In effect, tee duplicates its input, routing it to multiple outputs at once.


tee [OPTION]... [FILE]...


-a, --append Append to the given FILEs. Do not overwrite.
-i, --ignore-interrupts Ignore interrupt signals.
--help Display a help message, and exit.
--version Display version information, and exit.

If a FILE is specified as a dash ("-"), tee writes again to standard output.


ls -1 *.txt | wc -l | tee count.txt

In the above example, the ls command lists all files in the current directory that have the file name extension .txt, one file per line; this output is piped to wc, which counts the lines and outputs the number; this output is piped to tee, which writes the output to the terminal, and writes the same information to the file count.txt. If count.txt already exists, it is overwritten.

cat — Output the contents of a file.