学而时习之 又看到一篇
[root@localhost test]# cat e
info account times
info[3]: account[1] 141
info[3]: account[1] 109
info[3]: account[1] 3599
info[3]: account[1] 211
info[3]: account[1] 37
info[3]: account[2] 119
info[3]: account[3] 70
info[3]: account[3] 342
info[3]: account[1] 8
想要实现的效果:把相同account的time加到一起
info[3]: account[1] 4105
info[3]: account[2] 119
info[3]: account[3] 412
- [root@localhost test]# awk 'NR>1{a[$2]+=$3}END{for(i in a)print $1,i,a[i]}' e
- info[3]: account[1] 4105
- info[3]: account[2] 119
- info[3]: account[3] 412