title: Sum duplicate row values with awk
body: <p>I have a file with the following structure:</p>
  
  <pre><code>1486113768 3656
  1486113768 6280
  1486113769 530912
  1486113769 5629824
  1486113770 5122176
  1486113772 3565920
  1486113772 530912
  1486113773 9229920
  1486113774 4020960
  1486113774 4547928
  </code></pre>
  
  <p>My goal is to get rid of duplicate values in the first columns, sum the values in the second columns and update the row with new columns value: a working output, from the input above, would be:</p>
  
  <pre><code>1486113768 9936      # 3656 + 6280
  1486113769 6160736   # 530912 + 5629824
  1486113770 5122176   # ...
  1486113772 4096832
  1486113773 9229920
  1486113774 8568888
  </code></pre>
  
  <p>I know <code>cut</code>, <code>uniq</code>: until now I managed to find the duplicate values in first columns with:</p>
  
  <pre><code>cut -d " " -f 1 file.log | uniq -d
  
  1486113768
  1486113769
  1486113772
  1486113774
  </code></pre>
  
  <p>Is there a "awk way" to achieve my goal? I know it is very powerful and terse tool: I used it earlier with</p>
  
  <pre><code>awk '{print $2 " " $3 &gt;&gt; $1".log"}' log.txt
  </code></pre>
  
  <p>to scan all rows in log.txt and create a .log file with $1 as name, and filling it with $2 and $3 values, all in one bash line (to hell with <code>read</code> loop!); is there a way to find first column duplicates, sum its second column values and rewrite the row removing the duplicates and printing the resulting sum of second column?</p>