Hi,
I want to comapre two xml files in unix.
1st xml file contents
<application> abc </application>
<type>2</type>
<type1>3</type1>
2nd xml file contents.
<application> abc</application>
<type>2</type>
<type1>1</type1>
<type2>567</type2>
Desired output
Differences in 1st file
Name : Abc
<type1>3</type1>
Difference in 2nd file
Name : Abc
<type1>1</type1>
<type2>567</type2>
Basically i want to parse 2 xml files , if any difference is accoured then i want to parse the file in reverse way & get the text from <application> tag and redirect the text and all the differences occured in two files to 3rd file.
You can use commands in your script.
bash-3.00$ comm -23 a.xml b.xml | sed '1d'
<type1>3</type1>
bash-3.00$ comm -13 a.xml b.xml | sed '1d'
<type1>1</type1>
<type2>567</type2>
bash-3.00$ awk -F "[><]" '/application/{print $3}' a.xml
abc
1 Like
Thanks millan for your reply.
I have tried the given command , comm -23 a.xml b.xml | sed '1d' is not working for me. I think comm command 1st sort the file.The xml which I have pasted is just a sample. Actually the requirement is to compare the file which may contain the long text.
<application> abc </application>
<type>twetrwerwer</type>
<type1>werwerwerrftr</type1>
I am new to scripting world. Can I compare the files line by line, and while parsing them I want to always print the text which is there in 'application' tag & inderneath all the differences.
File is huge & it contains multiple 'application' tags.