title: Can I chain multiple commands and make all of them take the same input from stdin?
body: <p>In bash, is there a way to chain multiple commands, all taking the same input from stdin? That is, one command reads stdin, does some processing, writes the output to a file. The next command in the chain gets the same input as what the first command got. And so on.</p>
  
  <p>For example, consider a large text file to be split into multiple files by filtering the content. Something like this:</p>
  
  <pre><code>cat food_expenses.txt | grep "coffee" &gt; coffee.txt | grep "tea" &gt; tea.txt | grep "honey cake" &gt; cake.txt
  </code></pre>
  
  <p>This obviously does not work, because the second grep gets the first grep's <em>output</em>, not the original text file. I tried inserting <em>tee's</em> but that does not help. Is there some bash magic that can cause the first grep to send its <em>input</em> to the pipe, not the output?</p>
  
  <p>And by the way, splitting a file was a simple example. Consider splitting (filering by pattern search) a continuous live text stream coming over a network and writing the output to different named pipes or sockets. I would like to know if there is an easy way to do it using a shell script.</p>
  
  <p>(This question is a cleaned up version of my <a href="https://stackoverflow.com/questions/986017/filter-parts-of-a-file-into-different-files-in-a-single-command"> earlier one </a>, based on responses that pointed out the unclearness)</p>