range

If there were you, the world would be just right

第一列 $1

awk '{print $1}' code_top.log | sort | uniq -c | sort -nr -k1 | head -n 100

最后一列 $NF

awk '{print $NF}' code_top.log | sort | uniq -c | sort -nr -k1 | head -n 100

查看日志中"user/login",json key=client_ip 出现次数前10

cat access.api-sdk.9ringgames.com.log |grep "user/login" | awk -F '"client_ip":' 'match($2,/\"([^\"]*)\"/,a){print a[1]}' | sort | uniq -c | sort -nr -k1 | head -n 10

说明:

awk '{ print $1}' 取数据的第1列

awk '{print $NF}' 取数据的最后1列

sort 排序

uniq -c 打印重复行出现的次数

sort -nr -k1 按照重复行出现的次数排列,-k1以第一列为标准排序

head -n 10 取10条