grep表示日志文件中不包含某个单词的行

时间:2013-02-11 13:00:51

标签: regex logging grep

我正在尝试分析日志文件。我正在寻找一个正则表达式,它符合以下要求:

LOG: https://localhost/a
LOG: https://remotehost/x
LOG: https://localhost/b
LOG: https://localhost/c
LOG: https://remotehost/a

以上是日志文件的示例。 问题:如何浏览日志文件,以便只获取不包含的行:

https://localhost

结果应为:

LOG: https://remotehost/x
LOG: https://remotehost/a

1 个答案:

答案 0 :(得分:5)

使用grep -v <word> <filename>

来自grep手册(FreeBSD):

-v, --invert-match
    Invert the sense of matching, to select non-matching lines.
相关问题