--- layout: page category-page: intermediate category-title: Intermediate commands tags: tee output save author: Nicola Brunner title: tee previous-page: pages/cmd/interm/tar.html next-page: pages/cmd/interm/watch.html --- 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:

Example:

date | tee example.txt
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 would prefer to have content appended instead of overwritten on the file, should use -a flag on tee.