Linux Tee

 

teYou have taken some tea at some point but today I am offering you a Linux tee today.

tee(1) is small utility which copies standard input to stranded out but also to multiple files. Let us take an example to know how it works.

rahul@rahul-Aspire-4736Z:~$ ls | tee test | wc -l
23
rahul@rahul-Aspire-4736Z:~$ cat test
build
Desktop
Documents
Downloads
Eudyptula
examples.desktop
linkusage
linux
linux-3.15-rc2
Mail
Music
my_kernel_config
old_data
old_home
photorec.ses
Pictures
Public
rahul.tar.gz
sent
Templates
test
Videos
warning.txt

In above example, I did ls and pipe to “tee test” and again pipe to “wc -l”.
Output of ls when given to pipe it becomes standard input for another next process in our case tee which does copies it test file in addition to standard out which becomes standard input for wc command. The role of tee here to capture ouput of ls into test file in addition to passing it down to pipe for wc.
Enjoy!

Post a Comment

You must be logged in to post a comment.
%d bloggers like this: