Skip to main content

The `tee` utility copies standard input to standard output, making a copy in zero or more files. The output is unbuffered.

# Write the output both to the screen `STDOUT` and to the `filelist.txt`.
$ ls | tee filelist.txt

# The following command will take a backup of the crontab entries, and pass the
# crontab entries as an input to sed command which will do the substituion.
# After the substitution, it will be added as a new cron job.
$ crontab -l | tee crontab-backup.txt | sed 's/old/new/' | crontab –

# By default tee command overwrites the file. You can instruct tee command
# to append to the file using the option –a as shown below.
$ ls | tee –a file

# You can also write the output to multiple files as shown below.
$ ls | tee file1 file2 file3

## Reference: http://linux.101hacks.com/unix/tee-command-examples/