Don't depend on me, I need to be going back to my day job soon.
There's a number of ways to do this, obviously. The old-fashioned variant would be to remember the previous line and print that when you see the terminator. The really brute
Perl approach would be to slurp the whole file and substitute everything with an empty string except the line before the terminator. There's one in the
Perl FAQ about that;
perlfaq6 and scroll around for related questions. (The question about C comments further down the page has some hints, too.)
But the "previous line" solution is absolutely the simplest in this case, if you have no further requirements.
Code:
perl -ne 'BEGIN { $matching = 0; }
$matching = 1 if (m/^\*Main Start/);
next unless $matching;
print $prev if (defined $prev && m/^\*Main End/);
$prev = $_'