I need to extract the name value (Product Finder) from this xml:
File: config.xml
<?xml version="1.0" encoding="utf-8"?>
<widget id="com.abc.app" version="1.3.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0" ios-CFBundleVersion="1.3.1.5" android-versionCode="5">
<name>Product Finder</name>
<description>
Description
</description>
</widget>
I've tried:
mles$ cat config.xml | grep '<name>'
<name>Product Finder</name>
Some other answers suggest using grep -oPm1 "(?<=<xmltag>)[^<]+"
, but that yields an error:
mles$ cat config.xml | grep -oPm1 "(?<=<name>)[^<]+"
usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]
How can I get the name value? I need a solution without dependencies, so grep
would be preferred