linux 命令行记录

awk '{match($0,/level=([0-9]+)/,a);print a[1]}' game1logIn20160323.log | sort -nr | uniq -c

比较常用的几个

grep(已经熟练)

awk(练习中)

sort,uniq,cut 这几个比较简单。

 sed(只用过少数几次)

awk '{match($0,/act=(.*),uid=.*,price=([0-9]+).*/,a);print a[1],a[2]}' game1_twbuyRecord20170* | awk '{arr[$1_$2]=arr[$1_$2]+$2};END {for (item in arr) print item,arr[item]}' | sort

统计游戏中购买的表达式。直接统计的是各种和。

log]# awk '{match($0,/act=(.*),uid=([0-9]+).*,price=([0-9]+).*/,a);print a[1],a[3],a[2]}' game1_twbuyRecord20170* | awk '{arr[$1]=arr[$1]+$2};END {for (item in arr) print item,arr[item]}' | sort -k 2 -nr

统计各项支付的总和情况

awk '{match($0,/act=(.*),uid=([0-9]+).*,price=([0-9]+).*/,a);print a[1],a[3],a[2]}' game1_twbuyRecord20170* | awk '{arr[$3]=arr[$3]+$2};END {for (item in arr) print item,arr[item]}' | sort -k 2 -nr

根据uid统计每个人的消费总情况

awk '{match($0,/amount\"\:\"?([0-9.]+).*level\"\:\"?([0-9]+).*/,a);print a[2],a[1]}' game1_france_rmb_recharge_log201805* | awk '{arr[$1]=arr[$1]+$2};END {for (item in arr) print item,arr[item]}' | sort -n

根据等级,统计用户各个等级的充值情况

awk '{match($0,/amount\"\:\"?([0-9.]+).*level\"\:\"?([0-9]+).*/,a);print a[2],a[1]}' game1_france_rmb_recharge_log2018052* | awk '{arr[$1]=arr[$1]+$2;arr1[$1]=arr1[$1]+1;};END {for (item in arr) print item,arr[item],arr1[item]}' | sort -n

充值等级统计,带笔数

sort 使用-t分割,-k选择第几项,-n表示数字

猜你喜欢

转载自blog.csdn.net/zhjzhjxzhl/article/details/79743442
今日推荐