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

linux命令用来查看日志关键字

时间:2018-08-14 21:08:34      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:倒数   head   命令   str   http   包含   不同   dem   大小   

1、查看日志 前 n行

  cat 文件名 | head -n 数量

  demo:

    cat  test.log | head -n 200  # 查看test.log前200行

2、查看日志 尾 n行

  cat 文件名 | tail -n 数量

  demo:

    cat  test.log | tail -n 200  # 查看test.log倒数200行

3、根据 关键词 查看日志 并返回关键词所在行

  方法一:cat 路径/文件名 | grep 关键词

  demo:

    cat  test.log | grep "http"  # 返回test.log中包含http的所有行

  方法二:grep -i 关键词 路径/文件名  (与方法一效果相同,不同写法而已)

  demo:

    grep -i "http" ./test.log  # 返回test.log中包含http的所有行(-i忽略大小写)

linux命令用来查看日志关键字

标签:倒数   head   命令   str   http   包含   不同   dem   大小   

原文地址:https://www.cnblogs.com/television/p/9477478.html

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