START
03:11:30 a
03:11:40 b
END
START
03:13:30 eee
03:13:35 fff
END
jjjjjjjjjjjjjjjjjjjjj
START
03:14:30 eee
03:15:30 fff
END
ggggggggggg
iiiiiiiiiiiiiiiiiiiiiiiii
I want the below output
START
03:14:30 eee
03:15:30 fff
END
Basically i want to display the lines between START and END of last match occurrence
Please review the rules, which you agreed to when you registered, if you have not already done so.
If you did not post homework, please explain the company you work for and the nature of the problem you are working on. And, please also tell us the operating system and shell you're using. And, as RudiC asked, why sed ? This is much easier to do with ed or ex .
I have tried using grep and finding the line numbers of matched strings which worked but its time consuming because in the original scenario there will be thousands of lines between START and END and reading all these lines will be time taking which effects the automation. Looking to resolve it primarily through "sed" and secondarily "awk"
---------- Post updated at 05:35 PM ---------- Previous update was at 05:34 PM ----------
It's not a homework assignment. Its part of automation work for file handling.
You still haven't said why you can't use ed or ex for this. The following code is much simpler than anything you can do with awk or sed :
ed -s file.txt <<-"EOF"
?START?;/END/p
q
EOF
But, of course, this depends on using a shell that uses Bourne shell syntax and may be depending on a particular version of ed (depending on what OS you're using). Telling us what OS and shell you're using anything you start of thread in these forums allows people trying to help you avoid making wild assumptions about your environment and helps you get an answer that will work in your environment faster.