Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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.

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? – n0pe Aug 26 '11 at 20:53
@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

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