I have a xml file with the following structure:<object> <class = a> xyz </class> <class = b> xyz </class> <class = c> xyz </class> <class = d> xyz </class></object>I need to extract only some tags.For example : class = a and class = cTo remove a class I have the following command:sed -n '/<class name=a/,/<\/class/p' sourcefile.xml >> result.xmlSo, for two tags I could use the following:sed -n '/<class name=a/,/<\/class/p' sourcefile.xml >> result.xmlsed -n '/<class name=c/,/<\/class/p' sourcefile.xml >> result.xmlbut, two iterations would be made to the file. Is it possible to do it in a single iteration?Update:Output:<class = a> xyz </class> <class = c> xyz </class>
XML - Extract two or more tags in only one sentence using sed
linux;sed;xml