title: unix shell, redirect output but keep on stdin
body: <p>I'd like to have a shell script redirect stdout of a child process in the following manner</p>
  
  <ol>
  <li>Redirect stdout to a file</li>
  <li>Display the output of the process in real time</li>
  </ol>
  
  <p>I know I could do something like</p>
  
  <pre><code>#!/bin/sh
  
  ./child &gt; file
  cat file
  </code></pre>
  
  <p>But that would not display stdout in real time. For instance, if the child was</p>
  
  <pre><code>#!/bin/sh
  
  echo 1
  sleep 1
  echo 2
  </code></pre>
  
  <p>The user would see "1" and "2" printed at the same time</p>