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

相关推荐
hudd6683 分钟前
JavaEE 初阶 - 多线程(初阶)
java·开发语言·java-ee
CarIise17 分钟前
Java实训阶段查漏补缺复习笔记2
java·linux·算法
Wang's Blog24 分钟前
Java框架 SpringCloud 快速入门: Feign 的性能优化
java·spring cloud·性能优化
蛋蛋的就会顺顺的39 分钟前
hot100——二叉树
java·数据结构·算法·leetcode·力扣
打工仔折腾 AI1 小时前
System Prompt 替代 Few-shot:用规则约束大模型输出的省钱实践
java·人工智能·python·spring·langchain·prompt·ai agent 实战
一号弯1 小时前
Hyperv的LINUX虚拟机扩容
linux·运维·服务器
CarIise1 小时前
Java实训阶段查漏补缺复习笔记1
java·开发语言·笔记
缘友一世1 小时前
银河护卫队在steam(linux Proton GE-Proton10-34)上启动无窗口问题修复
linux·ubuntu·steam·proton
wunaiqiezixin1 小时前
MIT 6.S081 util 实验篇(lab1):primes (moderate/hard)
linux·unix·os·xv6·mit6.s081
一技安身2 小时前
VMware Workstation 25H2 创建兼容ESXi8.0虚拟机教程
服务器