Part 1
What is the easiest way to create a text filter which outputs only text surrounded by two predefined marks. I don't mind using any standard tool: sed, awk, python, ...
For example, i would like only the text surrounded by "Mark Begin" and "Mark End" to appear.
input:
Text 1
Mark Begin
Text 2
Mark End
Text 3
Mark Begin
Text 4
MarK End
Text 4
output:
Text 2
Text 4
Part 2
How can the solution be modified so that only the last occurrence will be written to output, so for the same input above, we get:
output:
Text 4