文本:
hash:0af1403ac9021973529b723cf9479633 date:7.6.0.2001
hash:0af1403ac9021973529b723cf9479633 date:7.6.0.2001
hash:f80cf7f9629c91aaa899e2256a6b4dac date:7.6.0.2001
hash:f80cf7f9629c91aaa899e2256a6b4dac date:7.6.0.2001
hash:f80cf7f9629c91aaa899e2256a6b4dac date:7.6.0.2001
hash:f80cf7f9629c91aaa899e2256a6b4dac date:7.6.0.2001
hash:f80cf7f9629c91aaa899e2256a6b4dac date:7.6.0.2001
hash:f80cf7f9629c91aaa899e2256a6b4dac date:7.6.0.2001
hash:f80cf7f9629c91aaa899e2256a6b4dac date:7.6.0.2001
hash:f80cf7f9629c91aaa899e2256a6b4dac date:7.6.0.2009
根据date统计hash的个数,重复的只算一个,得到结果:
7.6.0.2001 2
7.6.0.2009 1
- awk -F"[ :]" '!a[$2,$NF]++{b[$NF]++}END{for(i in b)print i,b[i]}' file
[解析]
把第2个字段和第4字段防入数组a中,去重后执行数组b的计数。
- awk -F"[ :]" -vc=1 '{if(x==$NF){if($2!=y)c++}else{if(NR>1){print x,c;c=1}}}{x=$NF;y=$2}' file <(echo)
[解析]
这个也是按照流程来执行比较,计数。
阅读(4486) | 评论(2) | 转发(0) |