Summing distinct rows

So the best way to describe this is to show an example:

IP1 GET url1 200 32IP2 GET url1 200 29IP1 GET url1 200 21

The "distinct rows" here would be "IP1 GET url1 200" and "IP2 GET url1 200". You could think of these as just a few
entries of the access_logs. Anyway, I wanted to sum together the times that these calls were taking (the last column).
Sometimes the number of fields varied so a general solution was needed.

The desired output is:

IP1 GET url1 200 53IP2 GET url1 200 29

and the script to do this is:

{# Grab the valuenum=0+$NF;# Strip the value - $0 no longer has the valueNF--;# Increments the value at hash[$0] or creates it# if not already present.hash[$0]=hash[$0]+num}END{for(ndxinhash){printndx,hash[ndx];}}