Professional Documents
Culture Documents
tee command reads the standard input and writes it to both the standard output and one or more files.
The command is named after the T-splitter used in plumbing. It basically breaks the output of a program
so that it can be both displayed and saved in a file. It does both the tasks simultaneously, copies the
result into the specified files or variables and also display the result.
In computing, tee is a command in command-line interpreters (shells) using standard streams which
reads standard input and writes it to both standard output and one or more files, effectively duplicating
its input. It is primarily used in conjunction with pipes and filters.
SYNTAX:
Options :
1.-a Option : It basically do not overwrite the file but append to the given file.
Suppose we have file1.txt
SYNTAX :
$ wc -l file1.txt|tee -a file2.txt
$ tee --help
SYNTAX :
$ tee –version
Tag Description
-a, --append
append to the given FILEs, do not overwrite
-i, --ignore-interrupts
ignore interrupt signals
--help display this help and exit
--version
output version information and exit
Application
Suppose we want to count number of characters in our file and also want to save the output to
new text file so to do both activities at same time, we use tee command.
$ wc -l file1.txt| tee file2.txt
Example