title: Shell script to remove everything in line after second comma and write to file?
body: <p>I have a CSV file that looks like this:</p>
  
  <pre><code>Wave 1,bob,IL
  Wave 2,julia,CO
  Wave 1,mark,WA
  Wave 2,fred,AK
  </code></pre>
  
  <p>I want to change it to look like this:</p>
  
  <pre><code>Wave 1,bob
  Wave 2,julia
  Wave 1,mark
  Wave 2,fred
  </code></pre>
  
  <p>I can use use <code>cut -d ',' -f 1-2 test.csv</code> to produce this result in stdout but I need to output to the same file being cut. I have tried <code>cut -d ',' -f 1-2 test.csv &gt; test.csv</code> and <code>stdbuf -o0 cut -d ',' -f 1-2 test.csv &gt; test.csv</code> but they both produce blank test.csv files.</p>
  
  <p>How can I remove everything after the second comma on a per line basis, and write the result in-place?</p>