Regex 如何使用负数正则表达式匹配grep-E?

Regex 如何使用负数正则表达式匹配grep-E?,regex,grep,Regex,Grep,我通过grep-E使用下面的正则表达式通过|管道匹配特定的字符字符串 $ git log <more switches here> | grep -E "match me" 我真正想要的是一个负匹配(返回所有不包含指定字符串的输出行,如下所示,但grep不喜欢它: $ git log <more switches here> | grep -E "^match me" 以下是从命令行返回的完整输出: match me once match me twice whate

我通过
grep-E
使用下面的正则表达式通过
|
管道匹配特定的字符字符串

$ git log <more switches here> | grep -E "match me"
我真正想要的是一个负匹配(返回所有不包含指定字符串的输出行,如下所示,但
grep
不喜欢它:

$ git log <more switches here> | grep -E "^match me"
以下是从命令行返回的完整输出:

match me once
match me twice
whatever 1
whatever 2

如何在每个负正则表达式匹配中获得所需的输出?

使用
-v
选项,该选项将反转匹配,选择非匹配行

另一个选项是使用
-p
,它将模式解释为Perl正则表达式

grep -P '^((?!match me).)*$'

awk'!/^match me/”文件
match me once
match me twice
whatever 1
whatever 2
grep -v 'match me'
grep -P '^((?!match me).)*$'