I'm trying to grep some text from my application log files and I really don't understand why it's not working... First I am extracting every part of the file that might have what I want, and later I want to exclude the ones that have some words that I don't want. The thing is that I want to remove the whole block that the first grep found, not only the line. I am trying this:
grep -A 5 "header of start parts" file.log | grep -v "piece of unwanted words" -A 2 -B 3
So I thought that using the -A 2 and -B 3 would remove the whole block in the second grep, but it is not what its happening. It's still giving me results with the unwanted words... This is the pattern of my file:
Some text to ignore
Some Text to ignore
header of start parts
line to get together
line to get together
line to get together
line to get together
line to get together
Some text to ignore
header of start parts
line to get together
line with piece of unwanted words
line to get together
line to get together
line to get together
A lot of other logs and this patterns repeating
So my first grep give me all the occurrences of this:
header of start parts
line to get together
line to get together
line to get together
line to get together
line to get together
and this:
header of start parts
line to get together
line with piece of unwanted words
line to get together
line to get together
line to get together
And the second grep I want to exclude all of this second block I posted. Thanks for any help in advance.