linux 中 利用 awk 数组 依据指定列的字符统计累计总长度
001、
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt ## 测试数据 a b c 3 d b e 7 a d e 8 z b c 4 a d e 1 [root@PC1 test]# awk '{array[$2] += $4} END {for(i in array) print i, array[i]}' a.txt ## 依据第二列的字符统计累计总长度 b 14 d 9


浙公网安备 33010602011771号