title: Best way to modify a file when using pipes?
body: <p>I often have shell programming tasks where I run into this pattern:</p>
  
  <pre><code>cat file | some_script &gt; file
  </code></pre>
  
  <p>This is unsafe - cat may not have read in the entire file before some_script starts writing to it. I don't really want to write the result to a temporary file (its slow, and I don't want the added complication of thinking up a unique new name).</p>
  
  <p>Perhaps, there is there is a standard shell command that will buffer a whole stream until EOF is reached? Something like:</p>
  
  <pre><code>cat file | bufferUntilEOF | script &gt; file
  </code></pre>
  
  <p>Ideas?</p>