Start_pattern
abc
d End_pattern
Start_pattern
abc
d
ef
ghij
klm
no End_pattern
Start_pattern
abc
def
hij End_pattern
Start_pattern
abc
dhi
jklm End_pattern
Just for completeness I add the sed
solution here :
sed -n '/Start_pattern/{:a;N;/End_Pattern/!ba;/ef/p}'
To understand this, you need to think of labels and branches as goto statements
Start_pattern
is found execute what is between {...}
a
with :a
N
)End_Pattern
is found do not goto label a
(!ba
)End_Pattern
is found, execute the last part which states that if the full record contains ef
, print the record.