Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

marked as duplicate by Michael Mrozek Feb 23 '11 at 15:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 7 down vote accepted

The command tee is exactly doing this :

cat /dev/stdin | tee $logfile
share|improve this answer
add comment

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