写点什么

Linux 指令日志分析 (一)

用户头像
正向成长
关注
发布于: 刚刚

在 Linux 系统进行日志定位需要从大量的日志中搜索有效信息,本文就日常使用到的grepawksort进行日志分析。


假设存在如下4.txt文件

2019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:02019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:102019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1002019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1012019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1022019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1112019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1122019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1042019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1082019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1052019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1062019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:12019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1072019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:10b2019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:10c2019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:10d2019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:10e2019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:10f2019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:112019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1102019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1132019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1032019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1142019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:1152019-1010-1920 192.345.23.3 Report 70b:a8dd:6f:116
复制代码

提取第三列信息

cat 4.txt | awk '{print $4}' 
复制代码

如果需要对提取的信息排序则执行

cat 4.txt | awk '{print $4}' | sort
复制代码

会得到如下信息

70b:a8dd:6f:070b:a8dd:6f:170b:a8dd:6f:1070b:a8dd:6f:10070b:a8dd:6f:10170b:a8dd:6f:10270b:a8dd:6f:10370b:a8dd:6f:10470b:a8dd:6f:10570b:a8dd:6f:10670b:a8dd:6f:10770b:a8dd:6f:10870b:a8dd:6f:10b70b:a8dd:6f:10c70b:a8dd:6f:10d70b:a8dd:6f:10e70b:a8dd:6f:10f70b:a8dd:6f:1170b:a8dd:6f:11070b:a8dd:6f:11170b:a8dd:6f:11270b:a8dd:6f:11370b:a8dd:6f:11470b:a8dd:6f:11570b:a8dd:6f:116
复制代码


发布于: 刚刚阅读数: 2
用户头像

正向成长

关注

正向成长 2018.08.06 加入

想要坚定地做大规模数据处理(流数据方向),希望结合结合批处理的传统处理方式,以及之后流批混合处理方向进行学习和记录。

评论

发布
暂无评论
Linux指令日志分析(一)