awk的二维数组需要用到split(i,o,SUBSEP);来二次拆分key来实现。
awk -F ',' 'BEGIN{count[$4,$5]=0;sum[$4,$5]=0;}
{count[$4,$5]+=$2;sum[$4,$5]+=$3;}
END{
for(i in count){
split(i,o,SUBSEP);
print o[1],o[2],count[o[1],o[2]],sum[o[1],o[2]];
}
}' out1_201812111133.txt
awk -F ',' 'BEGIN{val[$4,"a"]=0;val[$4,"b"]=0;}
{val[$4,"a"]+=$2;val[$4,"b"]+=$3;}
END{
for(i in val){
print i,val[i];
}
}' out2_201812111133.txt