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.

SYNTAX:
tee [OPTION]... [FILE]...
Options :
1.-a Option : It basically do not overwrite the file but append to the given file.
Suppose we have file1.txt
Input: geek
for
geeks
and file2.txt
Input:geeks
for
geeks
SYNTAX :
geek@HP:~$ wc -l file1.txt|tee -a file2.txt
OUTPUT :
3 file1.txt
geek@HP:~$cat file2.txt
OUTPUT:
geeks
for
geeks
3 file1.txt

2.–help Option : It gives the help message and exit.
SYNTAX :
geek@HP:~$ tee --help

3.–version Option : It gives the version information and exit.
SYNTAX :
geek@HP:~$ tee --version

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.
geek@HP:~$ wc -l file1.txt| tee file2.txt OUTPUT: geek@HP:~$15 file1.txt
Here we have file1 with 15 characters, so the output will be 15 and the output will be stored to file2. In order to check the output we use :
geek@HP:~$ cat file2.txt OUTPUT: geek@HP:~$15 file1.txt

Recommended Posts:
- 'IPCS' command in Linux with examples
- select command in Linux with examples
- Sed Command in Linux/Unix with examples
- ZIP command in Linux with examples
- SORT command in Linux/Unix with examples
- Cat command in Linux with examples
- Head command in Linux with examples
- Tail command in Linux with examples
- wc command in Linux with examples
- tar command in Linux with examples
- atrm command in Linux with examples
- bc command in Linux with examples
- AWK command in Unix/Linux with examples
- tr command in Unix/Linux with examples
- mv command in Linux with examples
- Paste command in Linux with examples
- comm command in Linux with examples
- cmp Command in Linux with examples
- cut command in Linux with examples
- cp command in Linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

