First, I am VERY new to shell, Java, Python, Perl, and any other Linux based scripting language. I am in need of doing something that I would think seems relatively simple, but can't get it to work. I have used awk and xpath (like awk output better, but doesn't seem as easy to use).
First, I'll show you the .xml output I need to parse:
Blockquote
<CLIOutput> <Data> <Row> <Name>PROD3_A2_LUN10</Name> <Type>VMFS</Type> <Accessible>Yes</Accessible> <Hosts>esx01s112</Hosts> </Row> <Row> <Name>PRIVATE_VDI_SDLC3_A2_LUN174</Name> <Type>VMFS</Type> <Accessible>Yes</Accessible> <Hosts>esx02s104</Hosts> </Row> <Row> <Name>datastore1</Name> <Type>VMFS</Type> <Accessible>Yes</Accessible> <Hosts>esx01s100</Hosts> </Row> </data> </CLIOutput>
I would ideally like to be able report not only on the XML attributes of "Name, Type, Accessible, and Hosts", but also report inside of those to only send an output that I want i.e. want to report on all "Name" that start with "P". My code attempts to date are:
* awk '$1~"^(" s ")$"{print $2}' RS=\< FS=\> s="Name" sdlcproxy1diff.xml -- shows me all "Name" items.| * xpath datastore.xml '/CLIOutput/Data/Row/*[self::Name]/text()' datastore.xml 2>/dev/null -- shows all "Name" items, but output is horrible.
Thanks in advance!!