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

相关推荐
正儿八经的少年12 分钟前
application.yml 系列配置文件作用与区别
java·配置文件
鱼很腾apoc40 分钟前
【学习篇】第20期 超详解 C++ 多态:从语法规则到底层原理
java·c语言·开发语言·c++·学习·算法·青少年编程
NightReader1 小时前
CPU 高使用率,怎么降下来
运维·服务器
cheems95271 小时前
[Spring MVC] 统一功能与拦截器实践总结
java·spring·mvc
SWAGGY..1 小时前
Linux系统编程:(七)Makefile入门:轻松掌握编译自动化
linux·运维·自动化
Full Stack Developme2 小时前
Spring Boot 事务管理完整教程
java·数据库·spring boot
开开心心就好2 小时前
免费流畅的远程控制实用工具
linux·运维·服务器·网络·智能手机·excel
城管不管2 小时前
前后端远程协作
java
青云计划2 小时前
Feed流
java·后端·spring
java1234_小锋3 小时前
String、StringBuilder、StringBuffer的区别?
java·开发语言