title: Best way to overwrite file with itself
body: <p>What is the fastest / most elegant way to read out a file and then write the content to that same file?</p>
  
  <p>On Linux, this is not always the same as 'touching' a file, e.g. if the file represents some hardware device.</p>
  
  <p>One possibility that worked for me is <code>echo $(cat $file) &gt; $file</code> but I wondered if this is best practice.</p>