How can I sum values in column based on the value in another column?

$ awk '{a[$1]+=$2}END{for(i in a) print i,a[i]}' file
ABC 80
XYZ 20
MNP 60
DEF 170

Leave a Comment