Shell 检查行是否不是以grep的特定字符串开头

Shell 检查行是否不是以grep的特定字符串开头,shell,grep,Shell,Grep,我有一个app.log文件 Oct 06 03:51:43 test test Nov 06 15:04:53 text text text more text more text Nov 06 15:06:43 text text text Nov 06 15:07:33 more text more text Nov 06 15:14:23 test test more text more text some more text Nothing but text some extra

我有一个app.log文件

Oct 06 03:51:43 test test
Nov 06 15:04:53 text text text 
more text more text
Nov 06 15:06:43 text text text
Nov 06 15:07:33
more text more text
Nov 06 15:14:23  test test
more text more text
some more text 
Nothing but text
some extra text
Nov 06 15:34:31 test test test
如何对所有非11月6日开始的行进行grep

我试过了

grep -En "^[^Nov 06]" app.log

我无法获取其中包含06的行。

只需使用下面的grep命令

grep -v '^Nov 06' file
grep--help

-v, --invert-match        select non-matching lines
又一次通过正则表达式进行的黑客攻击

grep -P '^(?!Nov 06)' file
正则表达式解释:

  • ^
    断言我们处于起点
  • (?!2006年11月)
    此负前瞻断言在行开始之后没有字符串
    2006年11月
    。如果是,则匹配每行中第一个字符之前存在的边界
通过PCRE动词的另一个基于正则表达式的解决方案


+1那真是太棒了!!我也刚刚得到答案:/但谢谢你:)
grep -P '^Nov 06(*SKIP)(*F)|^' file