EDIT: Did not mentioned before this is to be executed in OS X
I'm trying to create a bash script which will remove some blocks from a file and save the result to another one.
The file's content I want to filter should look like this:
<element>
<subElement name="leaveme"/>
<subElement name="leaveme"/>
<subElement name="leaveme"/>
</element>
<element>
<subElement name="removeme"/>
<subElement name="removeme"/>
<subElement name="removeme"/>
</element>
<element>
<subElement name="leaveme"/>
<subElement name="leaveme"/>
<subElement name="leaveme"/>
</element>
What I want to remove is the group including the <element></element>
tags which contains subelements <subElement name="removeme"/>
It's guaranteed that no group will have "removeme" and "leaveme" elements mixed.
I know how to do this with a regular expression like this:
<element>(?:(?!/elem).)*"removeme".*?</element>
but i'm really lost on how to do it in a shell script, had found some info about sed but did not understood how to acomplish that.
Thanks.