常用的linux命令查看日志

2023-07-02  本文已影响0人  燃灯道童

tail -f test.log 实时刷新最新日志

tail -100f test.log      实时刷新最新的100行日志

tail -100f test.log | grep [关键字]    查找最新的一百行中与关键字匹配的行

tail -100f test.log | grep '2019-10-29 16:4[0-9]'    查找最新的100行中时间范围在2019-10-29 16:40-2019-10-29 16:49范围中的行

如果是要查询16点08分到16点11分,这个表达式该怎么写呢?如果是15点到16点之间怎么写呢。

tail -1000f test.log | grep -A 5 [关键字] --查看最新的1000行中与关键字匹配的行加上匹配行后的5行

tail  -n  10  test.log  查询日志尾部最后10行的日志

tail -n +10 test.log    查询10行之后的所有日志

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

head -n -10  test.log  查询日志文件除了最后10行的其他所有日志

cat、more、vi、vim、sed等命令

原文链接:https://blog.csdn.net/weixin_44019406/article/details/102805197

如果是要查询16点08分到16点11分,这个表达式该怎么写呢?

tail -100f test.log | grep '2020-03-18 16:0[8-9]|2020-03-18 16:1[0-1]'

https://jingyan.baidu.com/article/656db918fccd01e381249c2b.html

上一篇 下一篇

猜你喜欢

热点阅读