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?

Let's say I do:

ps -ef | grep httpd

to see if apache is running or not, but I also want to "dump" the output of ps -ef into a file at the same time. Like this:

ps -ef  --- grep http
       |
        --- > file

Is it possible to fork STDOUT in parallel like this? The above is only an example so little hacks like dumping to the file and then grepping the file isn't what I'm looking for.

share|improve this question
add comment

marked as duplicate by Michael Mrozek Aug 26 '11 at 20:53

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

Sure. You are looking for tee not fork():

ps -ef | tee file | grep http
share|improve this answer
    
Oh that's what tee does! I've only come in contact with it a couple times but thanks for clearing that up. Does it work for the other standard streams? –  MaxMackie Aug 26 '11 at 20:53
1  
@MaxMackie: It works on whatever it is given. Unless you specifically tell the shell otherwise it will only receive the STDOUT of the proper being piped to it. –  Caleb Aug 26 '11 at 20:56
add comment

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