Edit: The modern (GNU/Linux) solution, as mentioned in comments years ago ;-) .
awk '{
arr[$1]+=$2
}
END {
for (key in arr) printf("%s%s
", key, arr[key])
}' file
| sort -k1,1
The originally posted solution, based on old Unix sort
options:
awk '{
arr[$1]+=$2
}
END {
for (key in arr) printf("%s%s
", key, arr[key])
}' file
| sort +0n -1
I hope this helps.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…