I want to use Sed to delete blocks of lines form a file, when first line matches pattern1 then continue deleting next lines until does NOT match pattern2 (or EOF), where pattern1 and pattern2 may or may not have overlap.
For example, with this input:
one
two
six
two
two
three
three
three
four
five
two
if pattern1=/two/ and pattern2=/three/, it should return:
one
six
four
five
I have tried sed /two/,/three/d
but it is not ‘greedy’ enough. And some solutions may not handle EOF properly.
DougCube is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.