• linux如何在日志中查找关键字、前几行、结尾几行


    查看日志 前 n行

    1  cat 文件名 | head -n 数量

    demo 

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

    查看日志 尾 n行

     2 cat 文件名 | tail -n 数量

    demo 

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

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

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

    demo 

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

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

      demo:

        grep -i "http" ./test.log  # 返回test.log中包含http的所有行

    世界上最美的风景,是自己努力的模样
  • 相关阅读:
    第五周作业
    第四周作业
    第三周作业(两个题)
    第六周作业
    第五周作业
    第四周作业
    第三周作业
    第二周作业
    求最大值及其下标
    查找整数
  • 原文地址:https://www.cnblogs.com/xiong-hua/p/13894196.html
Copyright © 2020-2023  润新知