Reputation: 2027
How can I (e)grep all content between a certain tag block?
Assume input file below, I want to get as output all characters between the B-tags so:
<B><C>Test</C></B>
<B>Test2</B>
I tried the following grep to search all XML files with the content between the <B>
and </B>
tags.
grep '<B>.*</B>' *.xml
but it did not work.
For the following input:
<A>
<B>
<C>Test</C>
</B>
<D>
</D>
<B>
Test2
</B>
</A>
Any ideas?
Upvotes: 1
Views: 4147