【问题标题】:Grep lines only if containing 2 specific strings仅当包含 2 个特定字符串时才 Grep 行
【发布时间】:2022-12-17 20:21:21
【问题描述】:

grep 行只有在其中包含 2 个特定字符串时才有可能吗?

我有这样的日志,我只想 grep 包含字符串“13/Dec/2022:11”的行“获取/fr/测试”

access.log:site.ch 111.222.333.444 - - [13/Dec/2022:11:40:00 +0100] "GET /fr/test HTTP/1.1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"

【问题讨论】:

    标签: shell grep


    【解决方案1】:

    只需 grep 两次:

    | grep "13/Dec/2022:11" | grep "GET /fr/test"
    

    【讨论】:

      猜你喜欢
      • 2016-07-29
      • 2012-08-04
      • 1970-01-01
      • 2021-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-22
      • 2019-08-09
      相关资源
      最近更新 更多