assuming that we have a file containing the following:
chapter 1 blah blah
blah num blah num
num blah num blah
...
blah num
chapter 2 blah blah
and we want to grep this file so we take the lines
from chapter 1 blah blah
to blah num
(the line before the next chapter).
The only things we know are
- the stating string
chapter 1 blah blah
- somewhere after that there is another line starting with
chapter
a dummy way to do this is
grep -A <num> -i "chapter 1" <file>
with large enough <num>
so the whole chapter will be in it.