十四、查看日志
1.0 cat -n xxx.log 查看文件并显示行号
2.0 head -n 10 xxx.log 查看文件前10行
3.0 head -n -10 xxx.log 查看文件至倒数第十行(最后10不显示)
4.0 tail -n 10 xxx.log 查看文件最后10行
5.0 tail -n +10 xxx.log 查看文件前10行
i) 根据关键词过滤
cat -n test.log |grep “关键词” ,获取到关键词所在行行信息及行号,假设行号为100
cat -n test.log |tail -n +90|head -n 20 ,获取[90, 110]行信息,即关键词前十行,后十行
ii) 根据日期 过滤
06-09
75
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-05
07-05
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交