I am looking for an awk or sed or grep or any other option in bash to group lines into sets based on a pattern, then exclude sets from the pool of sets based on a blacklist of words.
E.g., see example below, I'd like to print all sets which don't have "hello" and "idle" in them. The blacklist might be expanded with more words than these two, in the future.
I tried using awk & grep but not able to come up with a good solution to accomplish that.
$ grep -v "hello" test.out | more
row1 set 1
row2
--
row1 set 2
row2
row3 is "fine"
Input file test.out
row1 set 1
row2
row3 is "hello"
--
row1 set 2
row2
row3 is "fine"
--
row1 set 3
row2
row3 is "idle"
--
row1 set 4
row2
row3
...
--
row1 set n
row2
row3
expected output :
row1 set 2
row2
row3 is "fine"
--
row1 set 4
row2
row3
...
--
row1 set n
row2
row3