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
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
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.