【发布时间】:2019-05-16 02:39:09
【问题描述】:
我有一个包含各种日志行的文件,我想 grep 获取一个模式,但在 message:com.mycompany.excluded 时排除,所以基本上应该返回以下内容:
"The log found this message blah, message:com.blahblah"
"The log found this message blah2, message:com.blahblah2"
"The log found this message foobar, message:com.mycompany"
"The log found this message blah, message:com.mycompany.included"
但不是:
"The log found this message blah, message:com.mycompany.excluded"
我正在使用这种模式,但它不适用于排除 com.mycompany.excluded
grep "The log found this message.*message:.*" "mylogs.txt"
【问题讨论】:
-
您应该在示例中包含一些与
The log found this message.*message:.*不匹配的行,以便更清楚地表明您确实需要匹配该正则表达式。并根据您的示例输入添加预期输出。
标签: grep pattern-matching