grep with after-context that does not contain a keyword
- by ukasz
I want to grep through logs, and gather a certain exception stacktrace but I want to only see those that do not contain certain keywords in --after-context.
I do not know in which line in after-context the keyword is.
Simple example - given this shell code:
grep -A 2 A <<EOF
A
B
C
R
A
Z
Z
X
EOF
the output is:
A
B
C
--
A
Z
Z
I'd like the output to be:
A
Z
Z
I want to exclude any match that has 'B' in after-context
How do I do this? Using grep is not a requirement, though I only have access to coreutils and perl.