I have a text file like this
----PAT1----
textaa1
textbb1
textcc1
.......
----PAT2----
----PAT1----
textaa2
textbb2
textcc2
.......
----PAT2----
I want to extract the first text between "----PAT1----"
and "----PAT2----"
icluding both patterns
So the output will be:
----PAT1----
textaa1
textbb1
textcc1
.......
----PAT2----
How to do that with sed
or awk
?
I tried the following but it does not work
sed -n '/PAT1/,/PAT2/p' file
Other questions are showing how to extract all patterns, but they are not indicating how to extract only the first one