We need to extract multiple tag values from multiple files.
We have around 1000 files with data similar to:
<Employee>
<Id>432361</Id>
<EmpName>Stuart</EmpName>
<SidNumber>0251115</SidNumber>
<CreatedUtc>2016-11-14T22:27:53.477+08:00</CreatedUtc>
<EpisodeId>682082</EpisodeId>
<CorrelationId>323A6C86-76AA-E611-80DA-005056B46023</CorrelationId>
</Employee>
we need to extract EmpName, SidNumber and EpisodeId from all the files to a single file. we are able to get one value at a time, for ex. using command:
nawk -F'[<>]' '/<EpisodeId>/{print $3}' *.dat
But we need to get multiple tags of each file. the output format should be something similar to
EmpName Stuart SidNumber 0251115 EpisodeId 682082
EmpName Stuart SidNumber 0251115 EpisodeId 682082
or atleast space delimited values
Stuart 0251115 682082
Stuart 0251115 682082
any help would be appreciated.
Thanks in advance, Vivek
sedorawk, they are not the rigth tool for the job. go for some xml aware tool likexmllinthere is one way you should not do things , but will for fine for small xmls.declare $(awk -v FS='[<>]' 'length($3){print $2"="$3}' inputfile)thenecho $EmpName