代码之家  ›  专栏  ›  技术社区  ›  DeborahAnn

使用grep过滤进程的实时输出?如果是这样的话,赛后怎么排队[[副本]

  •  1
  • DeborahAnn  · 技术社区  · 7 年前

    我应该使用grep来过滤实时输出吗?我不确定这是否是我应该使用的实时输出。

    例子: command -option | grep --color 'string1\|string2'

    string1 string2

    1 回复  |  直到 7 年前
        1
  •  0
  •   lucascaro    7 年前

    正如@shelleter提到的 man grep :

     -A num, --after-context=num
             Print num lines of trailing context after each match.  See also the -B and -C options.
    

    command -option | grep -A 1 --color 'string1\|string2' 打印匹配的行和紧跟其后的行。

    在grep手册和大多数其他命令行程序中还有很多其他的选项,所以我建议您习惯于运行grep man cmd 作为第一次快速检查。