I have a file below where I want to sum up the third field and count, based on a group 1st and 2nd fields.File AAA~111~2 BBB~111~2 AAA~111~1 AAA~111~3 AAA~222~2Expected Output AAA~111~6~3 BBB~111~2~1 AAA~222~2~1So far, I have this code that only sums up the 3rd column awk 'BEGIN { FS=OFS=SUBSEP=~}{arr[$1,$2]+=$3 }END {for (i in arr) print i,arr[i]}' File
Group a file's contents by two fields and sum a third field
awk