title: Shell - Pipe to multiple commands in a file
body: <p>I want to run 2 commands on a piped-in input and want to print (to stdout) the output of both.</p>
  
  <p>Each command is a combination of grep, sed and awk.</p>
  
  <p>Both these commands must reside in a single .sh file.</p>
  
  <p>Sample commands:</p>
  
  <pre><code>cat mult_comm.sh       
  sed 's/World/Boy/g'|grep Boy ; grep World
  
  # Input
  cat input.log
  Hello World
  
  # This command HAS to work EXACTLY like this
  cat input.log | bash mult_comm.sh
  </code></pre>
  
  <p>Expected output</p>
  
  <pre><code>Hello Boy
  Hello World
  </code></pre>
  
  <p>Actual output</p>
  
  <pre><code>Hello Boy
  </code></pre>
  
  <p>I tried using tee</p>
  
  <pre><code>cat mult_comm.sh
  tee &gt;(sed 's/World/Boy/g'|grep Boy) | grep World
  </code></pre>
  
  <p>But this gives only </p>
  
  <pre><code>Hello World
  </code></pre>
  
  <p>I can modify the .sh file as I want but the piped command can't be changed. Any ideas?</p>
  
  <p>This is similar to <a href="https://stackoverflow.com/questions/10218103/osx-linux-pipes-into-two-processes">OS X / Linux: pipe into two processes?</a> and <a href="https://stackoverflow.com/questions/13107783/pipe-output-to-two-different-commands">Pipe output to two different commands</a>, but I can't figure out how to use named pipes inside the script.</p>