zoukankan      html  css  js  c++  java
  • grep 关键字显示上下行

    场景01

    • 查询的关键字"XXX process began"
    • 日志的名称 test_xxx.log
    • 显示关键字下方20行
      在日志test_xxx.log里根据关键字“XXX process began” 显示关键字的行和关键字之后的20行

    命令

    tail -10000 test_xxx.log |grep -A20  'XXX process began'
    

    场景02

    • 查询的关键字"XXX process began"
    • 日志的名称 test_xxx.log

    在日志test_xxx.log里根据关键字“XXX process began” 显示关键字的行和关键字之后的20行

    命令

    tail -10000 test_xxx.log |grep -B20  'XXX process began'
    

    场景03

    • 查询的关键字"XXX process began"
    • 日志的名称 test_xxx.log

    在日志test_xxx.log里根据关键字“XXX process began” 显示关键字的行和关键字之前的20行以及之后的20行

    命令

    tail -10000 test_xxx.log |grep -C20  'XXX process began'
    
    本人水平有限,还在不断学习中 难免有很多错误或者遗漏,望见谅
  • 相关阅读:
    day22-20180522笔记
    day20-20180517笔记
    day19-20180515笔记
    day18-20180513笔记
    day17-20180510笔记
    day16-20180508笔记
    Python之初识面向对象
    Python之常用模块(2)
    Python之常用模块(1)
    Python之模块与包(下)
  • 原文地址:https://www.cnblogs.com/faberbeta/p/15003097.html
Copyright © 2011-2022 走看看