Reputation: 5938
using a one line sed command , how could i get the something and someone value?
<value name="something">someone</value>
Using the following regex <value name="(.*)">(.*)<\/value>
i could retrieve the values with success using the site https://www.regex101.com/. But i'm not sure how could i do it using the command line.
Thanks in advance.
Upvotes: 0
Views: 58
Reputation: 246764
Noting the usual caveats about parsing XML with regular expressions, here's an XML parsing tool in action on your sample data that finds the attribute value and tag value for a "value" tag with a "name" attribute.
xmlstarlet sel -t -v '//value[@name]/@name' -n -v '//value[@name]' -n file.xml
something
someone
Upvotes: 0
Reputation: 26667
Something like
sed 's#.*name="\(.*\)">\(.*\)<.*#\1 \2#g'
Test
$ echo "<value name=\"something\">someone</value>" | sed 's#.*name="\(.*\)">\(.*\)<.*#\1 \2#g'
something someone
Upvotes: 1