Reputation: 1756
I have a xml file from which I want to extract the content inside of two xml tags similar to this:
<foo id="001">
... any String ...
</foo>
The starting tag line is unique due to the identifier, but the closing tag can appear any number of times. Is there a way to output the String inside those two tags using grep
?
Upvotes: 0
Views: 680
Reputation:
Try this magic:
grep -oPz '(?s)<foo id="001".*?</foo>\n' file.xml
where:
Upvotes: 2