shell常用命令及正则辅助日志分析统计
https://www.cnblogs.com/wj033/p/3451618.html
正则日志分析统计
3
grep 'onerror' v3-0621.log | egrep -v '(\dG|WIFI)'
grep 'onerror' v3-0621.log | egrep -v 'S-TO=C'
grep 'GET /view/' v3-0621page.log | egrep -c '2017:0|2017:1[0-5]|2017:16:[0-4]' (2017:00:00:00 - 2017:16:40:59)
grep 'GET /view/' v3-0622page.log | egrep 'forceReload' | egrep -c '2017:0|2017:1[0-3]'
IE版本分析
cd ../ 返回上一级
cd ~/ 返回到当前用户的根文件夹
cd ~-/ 返回到上一次的目录 类似电视遥控器的回看
创建新文件
touch err.txt
取前n行
head -10 103.log
取前n行,写入新文件
head -10 103.log > err.txt
grep -c "" 103.log
75350807
grep -c 'user-agent' 103.log
75350695
grep -c 'Mozilla' 103.log
73654756
grep -c '"user-agent":"Mozilla' 103.log
66630971
删除特定字符的行
sed -i '' '/28209/d' a.log
复制到新文件
grep '"user-agent":"Mozilla' 103.log > 1031.log
grep '"user-agent":"User-Agent' 103.log > 1030.log
grep -c 'Trident' 103.log
27286848
grep -c 'MSIE' 103.log
21675321 (和 21680763 总和比MSIE多了5442)
grep -c "MSIE " 103.log
21675152
grep -c 'MSIE 5' 103.log
772
grep -c 'MSIE 6' 103.log
707261
grep -c 'MSIE 7' 103.log
4340080
grep -c 'MSIE 8' 103.log
4682215
grep -c 'MSIE 9' 103.log
8393428
grep -c 'MSIE 10' 103.log
3557007
grep -c 'rv:11' 103.log
7650055
grep -c 'Edge/' 103.log
1209705
grep -c 'Firefox' 103.log
6059949
grep -c 'Opera' 103.log
1096765
grep -c 'Mobile' 103.log
1601204
grep 'user-agent' 103.log | grep 'MSIE' | grep 'Safari' > msie-safari.log
grep '' -c msie-safari.log
237133
grep 'user-agent' 103.log | egrep -v 'MSIE' | egrep -v 'rv:11' | egrep -v 'Safari' | egrep -v 'Firefox' | egrep -v 'Opera' > other.log
有MSIE没trident的
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)
有trident没MSIE的
grep -c 'MSIE 6' 103.log
grep 'user-agent' 103.log | egrep -v 'MSIE' | egrep -v 'rv:11' | egrep -v 'Safari' | egrep -v 'Firefox' | egrep -v 'Opera' > other.log
3353857
Minefield/
grep 'user-agent' tiny.log | grep -v 'QQ' | grep -v 'MicroMessenger' | grep -c -v 'MacIfox-Version'
2167881+329389