Question and answer based on my own question and answer in How to select lines between two patterns?
I have a file like the following and I would like to print the lines that appear between the patterns PAT1
and PAT2
.
1
2
PAT1
3 - primer bloque
4
PAT2
5
6
PAT1
7 - segundo bloque
PAT2
8
9
PAT1
10 - tercer bloque
I've read How to select lines between two marker patterns which may occur multiple times with awk/sed but I'm curious to see all the possible combinations, both printing the patterns and not.
How can I select the lines between two patterns?