How to suppress over-verbose xpath-output?
shell, xml, xpath
Solution
Found the solution. Simply append `2>/dev/null` to the command:
content=$(xpath ../../AndroidManifest.xml /manifest/@android:versionCode 2>/dev/null)
Output:
android:versionCode="38"
Problem
I'm using xpath (as supplied in Mac OS X 10.9 `usr/bin/xpath5.16`) in a shell script to parse some values from an XML file which works really well. However it gives me some verbose output which I don't want to see in my script. I actually only want to store the result (the content of the attribute) in a variable. ``` content=$(xpath ../../AndroidManifest.xml /manifest/@android:versionCode) echo "$content" ``` After execution the variable `content` indeed contains the content of the attribute, however there is also some verbose output I want to get rid of. Here it is: ``` Found 1 nodes: -- NODE -- android:versionCode="38" ``` Note: the "38" at the end of the output originates from the `echo "$content"` line the rest is the output of `xpath`.