I’m trying to use awk to add up the numbers from an output file, but it seems awk doesn’t understand the commas separating the thousands.
For example, running
awk '{if($1=="foo") {SUM+=$2}}END{print "foos ",SUM}'
on
foo 70.31
foo 125.00
foo 1,750.00
returns
foos 196.31
What’s the best/appropriate way in awk to add these up correctly?
Or, if you don’t want to clobber
$2: