I have a directory with thousands of file with following repetitive pattern containing hundreds of sections -
###############
# Section 1
###############
some text
more text
some more text
some text
more text
some more text
###############
# Section 2
###############
some text
more text
some more text
interesting-pattern
some text
more text
some more text
###############
# Section 3
###############
some text
more text
some more text
some text
more text
some more text
What i need to do is figure out a way to extract the entire SECTION where the "interesting-pattern" exists.
I have tried doing a grep -iEr 'interesting-pattern' with -A and -B flags but that doesnt work because in each file there could be different number of lines in the section before and after the intersting pattern.
What is the best way to do this?