Thursday, November 6, 2014

Markup tag stripping w/ SED

<?xml version="1.0" encoding="UTF-8" ?>
<Attributes>
   <Attribute>123</Attribute>
   <Attribute>959595</Attribute>
   <Attribute>1233</Attribute>
   <Attribute>jiji</Attribute>
</Attributes> 
To pull the second attribute:  
sed -n '/<Attributes>/,\#</Attributes>#{/<Attribute>/{
 n;s#.*<Attribute>\(.*\)</Attribute>.*#\1#;p;q};}'
 

No comments:

Post a Comment