using tee program with tar output

Carl Dichter dichter at chdasic.sps.mot.com
Sat May 11 00:42:26 AEST 1991


This will work in bourne:

	$ tar cvf tarfile /tmp 2>&1 | tee tar.out

But there is one caveat (and it is really true in any shell):
errors will come out immediately and normal output is buffered,
therefore it is harder to determine where an error actually occured.
Look at the following runs:

	$   tar cvf $HOME/tarfile $HOME/tardir
	a /home/libra/carl/tardir/afile 1 blocks
	a /home/libra/carl/tardir/myfile 2 blocks
	a /home/libra/carl/tardir/okfile 2 blocks
	tar: /home/libra/carl/tardir/yourbadfile: Permission denied

	$ tar cvf $HOME/tarfile $HOME/tardir 2>&1 | tee $HOME/tar.out2
	tar: /home/libra/carl/tardir/yourbadfile: Permission denied
	a /home/libra/carl/tardir/afile 1 blocks
	a /home/libra/carl/tardir/myfile 2 blocks
	a /home/libra/carl/tardir/okfile 2 blocks

The tee'd version has the message in a misleading place.

Have fun.

Carl R. Dichter 
Staff Software Engineer/Scientist
Motorola ASIC Division
Chandler, AZ 85224



More information about the Comp.unix.questions mailing list