I want to extract lines between two patterns (say, pattern1 and pattern2). The structure of the file is the following:
a random number of lines containing other stuff
pattern1
some lines to be extracted (finding out the number of lines possible, if necessary)
pattern2
a random number of lines containing other stuff
pattern1
some lines to be extracted
pattern2
a random number of lines containing other stuff
This repeats for a large number of times (i.e. there is a large number of matching pattern1-pattern2 pairs). I want to extract the lines between the patterns for all matches, effectively discarding the random stuff.
How can I do this?