Help with calculate total sum of same data problem

Long list of input file:

AGDRE1	0.1005449050
AGDRE1	2.1005443435
AGDRE1	1.2005449050
AGDRE1	5.1005487870
AASFV3	50.456304789
AASFV3	2.3659706549
AASFV3	6.3489807860
AASFV3	3.0089890148
RTRTRS	5.6546403546
.
.

Desired output file:

AGDRE1	8.5021829410
AASFV3	62.180245240
RTRTRS	5.6546403546
.
.

I would like to total up all the figure in column 2 if they share the same data in column 1.
Input file might up to few MB.
Thanks for any advice.

Try:

awk '{a[$1]+=$2}END{for (i in a){printf "%s\t%.10f\n",i,a}}' file
1 Like

Try this

 
perl -lane '$hash{$F[0]}+=$F[1];END{print "$_\t$hash{$_}" for keys %hash}' input
1 Like