How can we achieve this using sed or awk?
I have now included the text in a code block to make it clear.
The code block part should be printed - is the requirement.
LOGIC 1:
The text 'abc' will be our keyword here which will be unique and will only occur within the code block part
So we'll have to search for 'abc' and from that line till the last occurrence of 'abc' all lines should be printed inclusive
LOGIC 2:
Based on page numbers i.e. select text between page 1 and page n again inclusive Note: 'Page 1' and 'Page 1 - Page n' can come multiple times.
The whole text is a part of a 4GB file which needs to be parsed for similar occurrences.
Apologies for not being clear.
START OF TEXT IN THE FILE:
Xyz Page: 1
a
b
c
d
e
QWE Page: 1
e
r
t
y
asdabc Page: 1
t
y
u
I
o
ghjabc Page: 2
e
d
c
b
bnmabc Page: 3
uia
asd
ads
thm Page: 1
as
das
da