Linux ~ 查看日志的常用命令总结

1.tail

-n <行数>,显示文件的尾部n行内容。

-f 循环读取,常用于查阅正在改变的日志文件。

① tail -f test.log 实时显示test.log文件里的最尾部的内容,只要test.log更新就可以看到最新的文件内容。

② tail -100f test.log 实时监控100行日志。

③ tail -n 100 test.log 查询日志尾部最后100行日志内容。

复制代码
  ④ tail  -n  +100  test.log   查询100行之后所有的日志内容。

2.head

①head -n 100 test.log 查询日志文件中的头100行日志。

②head -n -100 test.log 查询日志文件中除了最后100行的其他内容。

3.grep

①grep "debug" test.log 查询test.log中所有含有debug关键字的记录

4.more和less

①cat -n test.log | grep "debug" test.log | more 这样就可以分页打印了,通过点击空格键翻页。

5.使用>xxxx.txt将查到的日志保存到文件中。

①cat -n test.log |grep "debug" >debug.txt

相关推荐
TAEHENGV3 分钟前
基本设置模块 Cordova 与 OpenHarmony 混合开发实战
android·java·数据库
用户61354114601611 分钟前
Krb5-libs-1.18.2-5.ky10.x86_64.rpm 安装失败怎么办?附详细步骤
linux
千寻技术帮13 分钟前
10422_基于Springboot的教务管理系统
java·spring boot·后端·vue·教务管理
milanleon22 分钟前
使用Spring Security进行登录认证
java·前端·spring
毕设源码-朱学姐26 分钟前
【开题答辩全过程】以 三叶草中石油信息管理系统的设计与实现为例,包含答辩的问题和答案
java·eclipse
期待のcode1 小时前
@RequestBody的伪表单提交场景
java·前端·vue.js·后端
SoveTingღ1 小时前
【问题解析】我的客户端与服务器交互无响应了?
服务器·c++·qt·tcp
气π1 小时前
【JavaWeb】——(若依+AI)-帝可得实践项目
java·spring
zhougl9961 小时前
Vuex 模块命名冲突:问题解析与完整解决方案
linux·服务器·apache