title: How to replace all occurrences in 1 file with sed?
body: <p>I need to replace all occurrences and write back to the same file</p>
  
  <p>I tried:</p>
  
  <pre><code>sed 's/one/two/g' file.txt
  </code></pre>
  
  <p>this print out but does not write to file</p>
  
  <p>I also tried</p>
  
  <pre><code>sed 's/one/two/g' file.txt&gt;file.txt
  </code></pre>
  
  <p>This results in empty file</p>
  
  <pre><code>sed -i 's/one/two/g' file.txt
  </code></pre>
  
  <p>gives error: <code>sed: 1: "file.txt": invalid command code f</code></p>
  
  <p>Any idea?</p>