我使用以下正则表达式通过 grep -E
命令匹配一个特定字符字符串,使用 |
管道符隔开。
$ git log <more switches here> | grep -E "match me"
输出:
match me once
match me twice
我需要的是一个负匹配(返回所有不包含特定字符串的输出行),类似于以下示例,但 grep 无法处理:
$ git log <more switches here> | grep -E "^match me"
期望输出:
whatever 1
whatever 2
以下是来自命令行的完整输出结果:
这里是来自命令行的完整输出结果:
match me once
match me twice
whatever 1
whatever 2
如何通过负正则表达式匹配获得所需的输出?
awk '!/^match me/' file
- Jotne