Here is a sample file which provides counts of how many times a record is duplicated in a file
2 D1111111111 AAAAAA
2 D2222222222 BB2222
2 D3333333333 CC3333
39 D4444444444 EE4444
2 T5555555555 DD5555
2 D6666666666 FF6666
2 T7777777777 GG7777
2 D8888888888 HH8888
The first field in the row is a count of how many times the record appeared in a file. Everything after that is the duplicate row
I would like to do the following:
for every row where the 2nd field starts with D, sum the 1st field.
So what I am expecting is the sum= 2+2+2+39+2+2 = 49 (the 2 rows that commenced with T is excluded)
I don't suspect this file of duplicates to be long, however I have been trying to accomplish this using awk and grep as a one liner, rather than a line by line reading of the file in a for loop
Any help is appreciated.