I want to know the sum of values in a field for every variable in another field. For example for the following input I want to know the sum of values in 3rd column for every value in 1st column:
a x 3
b y 4
a y 2
b x 5
The output should be:
a 5
b 9
My data is in tsv format. I might want something like this:
awk -F'\t' 'BEGIN{SUM=0}{ SUM+=$3 }END{print SUM}'
but for every value of column 1. I found a related question here but as I am very new to awk scripting I am not able to modify the given awk script for my purpose.
I don't have datamash installed so I need a solution with awk and for loop.
Thank you