一、实例
单条日志模板:
2018-11-08 02:17:22 [Iceberg]process params:IcebergOfferServiceImpl.Params(pk=BF06NA2YEE60DKXVL0ARUJ5N, ua=Mozilla/5.0 (Linux; Android 6.0.1; SM-A500F Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Ge
cko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36, gd=1b56f589-70e4-4596-863e-d0c02bb4ef57, co=RU, ln=RU, sn=6.0, sc=23, pn=com.galaxys.launcher, cv=49, cn=4.8, nt=WIFI, ss=720x1280, rm=1892, st=
0, af=android, igi=0, irt=0, aid=)
需求:
解析出上面的gd字段,去重,并统计一共多少条
实现:
cat debug.log|grep "process params:"|awk -F " gd=" '{print $2}'|awk -F ", co=" '{print $1}'|uniq|wc -l
效果:
20566
二、命令解析
- cat debug.log
- grep "process params:"
- awk -F " gd=" '{print $2}'|awk -F ", co=" '{print $1}'
- uniq
- wc -l