title: Is it OK to use the same input file as output of a piped command?
body: <p>Consider something like:</p>
  
  <pre><code>cat file | command &gt; file
  </code></pre>
  
  <p>Is this good practice? Could this overwrite the input file as the same time as we are reading it, or is it always read first in memory then piped to second command?</p>
  
  <p>Obviously, I can use temp files as intermediary step, but I'm just wondering..</p>
  
  <pre><code>t=$(mktemp)
  cat file | command &gt; ${t} &amp;&amp; mv ${t} file
  </code></pre>