I am trying to manipulate a range of lines between two patterns, "start" & "end". The two patterns can be on the same line or different line. Here are two sample blocks from the file:
Blk1:
start blah blah blah blah end
or
Blk2:
start blah blah blah
blah blah blah blah
blah blah end
I was trying to use the Perl's range operators .. or ...
The problem is that if I use .. Blk1 does not match because the two patterns are true on the same line. But if I use ... a Blk2 following Blk1 gets mixed up because once it finds "start", it goes to the next line till it finds the "end" which causes the two blocks to get mixed up.
Is there a way to mix the .. & ... to get what I am looking for? Or any other better way to extract a range of lines between two patterns?
Thanks a lot!!


Reply With Quote
Bookmarks