Possible Duplicate:
Is there a way in bash to redirect output and still have it go to stdout?

How would I send /dev/stdin to both /dev/stdout and a $logfile in one command?

One solution would be just to do it once for both:

 cat /dev/stdin > $tempfile;
 cat $tempfile > /dev/stdout;
 cat $tempfile > $logfile;

But that seems bad. Is there a better way?

  • I remember this question being ask before.
    – phunehehe
    Feb 23 '11 at 12:42
  • 2
    This is a duplicate. This is related.
    – phunehehe
    Feb 23 '11 at 12:53

The command tee is exactly doing this :

cat /dev/stdin | tee $logfile

Not the answer you're looking for? Browse other questions tagged or ask your own question.