I want to pipe the output of a program to another program in addition to STDOUT. The way I am doing it right now is to tee the output to a temporary file that I then delete but would be interested in knowing about better approaches where I don't have to create a temp file. Here is my code that shows what I am doing right now:
random=`echo $RANDOM`
filename='/tmp/'$random
foo | tee $filename
cat $filename | bar
rm $filename
In above foo and bar are my programs. What I want is to pipe the output of foo to bar but also have foo display its output to STDOUT. If I just do:
foo | bar
the output to STDOUT is lost.
foo | tee /dev/tty | bar?