--- layout: page category_title: interm category-page: interm tags: tee shell command author: Nicola Brunner title: tee ---

The tee command is used to split the output of a program, doing this the output can be displayed in the shell and in the same time written in a file. This is useful, for example, if we want to capture intermediate outputs of a long program. The command is named after the T-splitter used in plumbing, because they have similar functions.


Usage:

The default tee command syntax is:

tee [flags] [file]

Where [flags] are the tee flags (below you will find more info), and argument [file] is a file or a list of files, each of which receives the output.


Flags:

The most common flags of tee are:


Example:

date | tee example.txt

Basically, with this example, we can see that tee writes the date in example.txt, but shows also the output (in this case the date) in the shell. If you wouldn’t your file be overwritten every time you use this command, you should use -a that appends the output to the file.