在下面的统计数据:
2018/04/08 14:48:12 2018-04-08T14:48:12.257012513+08:00|6939cca7f50b0|GET|/test/api|127.0.0.1|curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3|Nyr9oRgz
2018/04/08 14:48:12 2018-04-08T14:48:12.274004854+08:00|6939cca7f50b0|GET|/test/api|127.0.0.1|curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3|Nyr9oRgz
2018/04/08 14:48:14 2018-04-08T14:48:14.994704416+08:00|6939cca7f50b0|GET|/test/api|127.0.0.1|curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3|UY9qd0jx
2018/04/08 14:48:15 2018-04-08T14:48:15.009452495+08:00|6939cca7f50b0|GET|/test/api|127.0.0.1|curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3|UY9qd0jx
2018/04/08 14:48:16 2018-04-08T14:48:16.60765182+08:00|6939cca7f50b0|GET|/test/api|127.0.0.1|curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3|0mSAciQ1
2018/04/08 14:48:16 2018-04-08T14:48:16.615372223+08:00|6939cca7f50b0|GET|/test/api|127.0.0.1|curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3|0mSAciQ1
(1)
统计第二栏出现的次数和百分比:
cat info.log.2018.04.07|awk -F '|' '{ s[$2]++}END{for( i in s) print i,s[i],s[i]/NR*100 "%"}'|sort -rn -k2
结果样例:
f3d325f075da43a 378215 12.2701%
d7e6866930e1764 209953 6.8113%
0c9f16007b1849c 198566 6.44188%
(2)
不统计百分比:
cat info.log.2018.04.17|grep "app"|awk -F '|' '{print $2}'|sort|uniq -c|sort -rn|more
结果样例:
14 d7e6866930e17
12 a51c88b7526cc
9 132086584a612
7 783e88a15967c