I am trying to extract the trace of a specific event from log files. To find the relevant event, I look for a $PATTERN$. To extract the complete trace of the event, I am looking to extract lines on either end of the pattern enclosed by a $SEPARATOR$
For example, if the contents of log file is
Line1
Line2
SEP
Line3
Line4
Name=PATTERN
Line5
SEP
Line 6
...
I want to extract
SEP
Line3
Line4
Name=PATTERN
Line5
SEP
I tried to use sed and got it working for single line matches as below:
echo "randomStringSEPrandomPATTERNrandomSEPrandom" | sed -n 's/^.*\(SEP.*PATTERN.*SEP\).*/\1/p'
returns SEPrandomPATTERNrandomSEP
Any help on how to extend it for multiple lines would be much appreciated. Thanks.