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.


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.


  • -a Appends the output to each file, rather than overwriting it.
  • -i Ignores interrupt signals.


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.