【问题标题】:How to make tail display only the lines that have a specific text?如何使尾部仅显示具有特定文本的行?
【发布时间】:2013-08-18 02:15:57
【问题描述】:

如何让tail只显示有特定文字的行?如果搜索条件可以是正则表达式,那就更好了。我需要类似的东西:

tail -f mylogfile.log showOnlyLinesWith "error: "

我正在运行 Darwin (Mac OS X),我完全是 bash 的初学者。

【问题讨论】:

    标签: shell unix tail


    【解决方案1】:

    你可以的

    tail -f mylogfile.log | grep "error: "
    

    这也适用于正则表达式。一般来说,你可以取任意命令的输出,将|添加到“管道”到grep中,让grep过滤掉不匹配特定模式的行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      • 1970-01-01
      • 2012-03-24
      • 1970-01-01
      • 2021-03-13
      • 1970-01-01
      相关资源
      最近更新 更多