I want to use grep with regex to match part of a line, then proceed to print that line and the next 2 lines. But I don’t want to print any match where the second line after the match includes another regex pattern.
Example text:
If the line was there is a loom in the gloom
would you want that line printed?
Just trying to understand if you're just
other than as part of gloom
if you really do want to exclude lines
even when loom appears on it's own elsewhere on the line
Searching for the pattern, gloom; using grep -Pn -A2 '^.*\b(gloom)\b.*$' * will print
If the line was there is a loom in the gloom
would you want that line printed?
Just trying to understand if you're just
..and
other than as part of gloom
if you really do want to exclude lines
even when loom appears on it's own elsewhere on the line
But I don’t want to print the second group that includes the word, elsewhere, on its third line. Using Perl-regex.