码迷,mamicode.com
首页 > 系统相关 > 详细

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

时间:2019-08-01 11:52:20      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:deb   最新   pre   显示   log   查询日志   div   txt   sof   

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

    

 

  

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

标签:deb   最新   pre   显示   log   查询日志   div   txt   sof   

原文地址:https://www.cnblogs.com/honeyJYY/p/11281410.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!