awk programming

Good morning to everyone!

guys, help me please

I have a file like this one:

diamond 5 7.8
77777765 1 7
1234567890 9 3.5
diamond 2 1
1234567890 3 6.8
77777765 0 4

os Solaris

it's only example, columns may be more, but in my case only 3 columns

so, my question
how I can group according to the first column and the rest to add up on awk or something else?
sorry for my bad english, let me write to you like sql

select column1, sum(column2), sum(column3)
from table_blabla
group by column1

Could you help me with this case?

Try...

awk '{a[$1]+=$2;b[$1]+=$3}END{for(c in a)print c,a[c],b[c]}' file1
1 Like