I have the following regex that works for me in sed:
cat <<EOF | sed -E '/^([A-Z][a-z]+){2,}$/Q'
Nothing Relevant
TotallyFake:
- NowWeWant
- TheseLines
- AndAlsoThisLine
ButNotThisLine
- OrThisLine
EOF
This only outputs the lines we want... but also the header lines, which is less good. So I lookes around and found the /this/,/that/
approach, and thought, cool! I can find the first PascalishCase thing and then break at the first empty line.
So I tried this:
cat <<EOF | sed -En '/^- ([A-Z][a-z]+){2,}$/,/^$/p'
Nothing Relevant
TotallyFake:
- NowWeWant
- TheseLines
- AndAlsoThisLine
ButNotThisLine
- OrThisLine
EOF
However... it gives me OrThisLine
. which is far less desirable.
How can I just use sed to find the first block of PascalText beginning with a -
and only print those lines?
[edit]
Since the contents weren't clear enough, the output I want is:
- NowWeWant
- TheseLines
- AndAlsoThisLine
My understanding was that /this/,/that/
would find the first this
and go to the first that
after "this", but the ^$
pattern isn't matching the first blank line, it appears to be matching EOF.
sed
to process it, depending on what it is you're actually wanting to do. – Kusalananda Jan 20 '23 at 07:05