Tuesday Tiny Techie Tip

tee(1)

Sometimes you want to be able to monitor the progress of a long running process, but you also want to save a transcript of its output so you don't have to watch it every second.

tee was designed with this very purpose in mind.


% ls -l | tee foobar
total 26
-rw-r--r--  1 jeffy          28 May  9 16:12 Makefile
-rwxr-xr-x  1 jeffy       24576 May 28 11:31 foo
-rw-r--r--  1 jeffy          57 May  9 16:13 foo.c
% ls
Makefile        foo             foo.c           foobar
% cat foobar
total 26
-rw-r--r--  1 jeffy          28 May  9 16:12 Makefile
-rwxr-xr-x  1 jeffy       24576 May 28 11:31 foo
-rw-r--r--  1 jeffy          57 May  9 16:13 foo.c

Keep in mind that tee only duplicates stdout, so if you want to save error output (you probably do), you'll need to combine stderr onto stdout with "|&" if you're in csh-land, or "2>&1" if you're playing with sh.

Also note that tee accepts a "-a" flag which tells it to append its output to the file instead of truncating the file first.

Why's it called tee, you ask? Named after the pipe fitting that looks like a letter "T" and sends its input to two different places.

tee is also distinguished by having one of the shorter man pages in UNIXdom.


% cd /vobs/App/Mr
% clearmake |& tee Transcript


Tuesday Tiny Techie Tip -- 27 May 1997
Forward to (06/03/97)
Back to (05/20/97)
Written by Jeff Youngstrom

Up to the TTTT index

Tuesday Tiny Techie Tips are all © Copyright 1996-1997 by Jeff Youngstrom. Please ask permission before reproducing any of this material.