How to find a phrase and pull all lines that follow until the phrase occurs again?

I want to burst a report by using the page number value in the report header. Each section starts with

*PAGE NO:* 1

Each section might have several pages, but the next section always starts back at 1.

So I want to find the "PAGE NO: 1" value and pull all lines that follow until "PAGE NO: 1" appears again.

I've tried using awk search for the phrase and pull newline characters but I can't rely on a set number of lines that follow the phrase.

Thank you!

-Scottie1954

I don't know the format of the file you're trying to parse or any other info, but this sed command can grab the lines between two given patterns (excluding said patterns):

sed -n '/<pattern1>/,/<pattern2>/{//!p};'
awk '/PAGE NO:\* 1$/ { P=!P ; next } P' inputfile > outputfile

Yeah, I've been a bit cryptic with what's in the file as it has mostly confidential data. It would take some effort to redact. Anyway, I've tried both replies here with no luck. The sed suggestion produces a parsing error and the awk returns no data. I'm running /usr/bin/sh on hp-ux.

The number that I want to search between is in the last column of the report header. If I use the following code I can see the numbers change, but I don't know how to grab the lines in between. Thank you.

grep 'PAGE NO:' reportfile | awk '{ print $NF }'

You probably just need to tweak the awk version's regex until it starts matching the "page number" lines. We can't do that for you, since you can't post the data...