I'd like to find lines with
p and get the content between the tags ...
<main>Nothing</main> <h2>Hello</h2><p>World</p> <h2>Bells</h2><p>Walls</p> <h2>Jelly</h2><p>Minus</p> <p>Fluff</p>
... into a tab separated list:
Hello World Bells Walls Jelly Minus
I currently use:
grep -E "<h2>(.*)<\/h2><p>(.*)<\/p>" | sed -E "s/<h2>(.*)<\/h2><p>(.*)<\/p>/\1 \2/"
However, I find it sort of annoying that I have to first
grep <pattern> and then do
sed <the same pattern>. Is it possible to do this using a single utility, using the pattern only once?