How to remove XML tags from Unix command line?
command-line, shell, unix, xml, xml-parsing
Solution
If your file looks just like that, then `sed` can help you:
sed -e 's/<[^>]*>//g' file.xml
Of course you should not use regular expressions for parsing XML because it's hard.
Problem
I am grepping an XML File, which gives me output like this: ``` <tag>data</tag> <tag>more data</tag> ... ``` Note, this is a flat file, not an XML tree. I want to remove the XML tags and just display the data in between. I'm doing all this from the command line and was wondering if there is a better way than piping it into awk twice... ``` cat file.xml | awk -F'>' '{print $2}' | awk -F'<' '{print $1}' ``` Ideally, I would like to do this in one command