bash script, pattern matching + sum

Hi guys, i have been struggling to achieve the following and therefor looking for some help.
I am trying to write something that will summerize the following output from my switches for daily totals.
Basicly if $1 $2 $3 doesnt change, we can keep adding up $4. Probably would use a awk print end statement but i cant get to work as it should. I tried inserting the data into arrays but that didnt work as well. Clearly im lacking the skills heh :o any form of help would be appreciated :b:

Into the following output...

Thanks in advance

This should summerize the fourth column based on the first 3 fields as key:

awk '{a[$1FS$2FS$3]+=$4}END{for(i in a){printf("%s %ld\n", i, a)}}' file

Regards

$ awk '{ind=sprintf("%s %s %s",$1,$2,$3);s[ind]+=$4}END {for(i in s){print i,s}}' h.in | sort
SW01 4/21 ALIGNMENT_ERROR 598
SW01 4/21 FCS_ERROR 598
SW01 4/21 IN_ERRORS 666
SW01 5/17 OUT_DISCARD 1323280
SW01 5/33 OUT_DISCARD 405722
SW02 2/27 ALIGNMENT_ERROR 598
SW02 5/6 RUNTS 9831

My output does not tally with yours, may i know how you get the number, it does seem to be the sum

Franklin52,
I'm very impressed! You gave me a oneliner doing exactly what i have been struggling with. :b: :smiley:

Chihung,
that is correct as mine was an example.