bash command(sed) to remove XML Node -


i'm trying create bash command delete particular node in xml if contains string starting particular few characters

for e.g.
if xml this:

  <x>    <y> abc... </y>    <y> trf... </y>    <y> abc... </y>   </x> 

then i've remove such y nodes have values starting abc... string

in end, should remain below:

<x>    <y> trf... </y>  </x> 

i searching , found, 'sed' commmand similar of regular expressions. trying read various other similar questions on site , tutorials getting overwhelmed

i know, asking kind-of spoon feeding please suggest if can done i've next few hours available before i've start associated activity!

also there easy tutorial on 'sed' finding learning , understanding little complex ..whatever found till on net.

thanks !

if open use awk , following command can used print line not contains abc in it.

 awk '!/<y> abc/' xml  <x>    <y> trf... </y>   </x> 

or

awk ' /<x>/,/<\/x>/  {if($0 !~ "<y> abc") print $0}' xml 

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -