I have a file 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
How do I grep all the lines that does not begin with Nov 06 ?
I have tried
grep -En "^[^Nov 06]" app.log
I am not able to get lines which have 06 in them.
Simply use the below grep command,
grep -v '^Nov 06' file
From grep --help
,
-v, --invert-match select non-matching lines
Another hack through regex,
grep -P '^(?!Nov 06)' file
Regex Explanation:
^
Asserts that we are at the start.(?!Nov 06)
This negative lookahead asserts that there isn't a string Nov 06
following the line start. If yes, then match the boundary exists before first character in each line.Another regex based solution through PCRE verb (*SKIP)(*F)
grep -P '^Nov 06(*SKIP)(*F)|^' file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With