Sponsored Content
Top Forums Shell Programming and Scripting Compare two unsorted unequal files extracted from xml Post 302891505 by vamsi gunda on Thursday 6th of March 2014 07:14:22 AM
Old 03-06-2014
Compare two unsorted unequal files extracted from xml

I have two files for comparison which are extracts from set of xml files.

file1 has:
Code:
Comparing File: BRCSH1to320140224CC3.xml
 :: TZZZ:BR
 :: TAZZ:OUT
UIZZ:0 :: ERAZ:1.000000
UIZZ:0 :: CTZZ:B
UIZZ:0 :: CCAZ:MYR
Comparing File: BRMY20140224CC18REG013SPFNSY13.xml
 :: TZZZ:BR
 :: TAZZ:INB
UIZZ:1 :: ERAZ:1.000000
UIZZ:1 :: CTZZ:B
UIZZ:1 :: CCAZ:MYR
Comparing File: BRMY20140224CC19REG015DRTZ3.xml
 :: TZZZ:BR
 :: TAZZ:INB
UIZZ:1 :: ERAZ:1.000000
UIZZ:1 :: CTZZ:B
UIZZ:1 :: CCAZ:MYR
UIZZ:1 :: CTZZ:L

file2 has
Code:
To File: BRCSH1to320140224CC3.xml
 :: TZZZ:BR
 :: TAZZ:OUT
UIZZ:0 :: ERAZ:1.000000
UIZZ:0 :: CTZZ:B
To File: BRMY20140224CC19REG015DRTZ3.xml
 :: TZZZ:BR
 :: TAZZ:INB
UIZZ:1 :: ERAZ:1.000000
UIZZ:1 :: CTZZ:B
UIZZ:1 :: CCAZ:MYR
UIZZ:1 :: CTZZ:L

Now i'm getting results when the number of lines are equal in both the files with the below script.

Code:
diff -y source.txt target.txt | grep "|" | awk -F"[<|>]" '{ if( $1 ~ /^Comparing/ ) { print $1 $2} else { print "Expected value is:"$1 "Actual value is:" $2}}' >> Discrepancies.txt

But if I were to compare if the above is the file contents,I have to take what kind of implementation.

Last edited by Scrutinizer; 03-06-2014 at 08:38 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Shell Script to compare xml files and print output to a file

All, PLease can you help me with a shell script which can compare two xml files and print the difference to a output file. I have attached one such file for you reference. <Group> <Member ID=":Year_Quad:41501" childCount="4" fullPath="PEPSICO Year-Quad-Wk : FOLDER.52 Weeks Ending Dec... (2 Replies)
Discussion started by: kanthrajgowda
2 Replies

2. Shell Programming and Scripting

include file name to extracted files

I've written the script below to merge only .txt files that exist in one directory into one huge .txt file and ignore other files with other extensions. now the result is one huge .txt file with all the contents of other .txt files how can i add a File Name as a comment before each file? ... (12 Replies)
Discussion started by: miss_dodi
12 Replies

3. Shell Programming and Scripting

Comparing two unsorted files

Hi Guys, I'm a complete shell scripting newbie and need some help with comparing a file against a master file and outputting the results. master.txt would look something like this: 000123 000345 000341 000927 000762 000235 000155 000452 000846 000623 file.txt would look like... (1 Reply)
Discussion started by: ven
1 Replies

4. Shell Programming and Scripting

Make new files based on the number extracted

Hi All, I have a big file which looks like this: 0 4.5 6.7 0 3.4 6 1 5 6 1 6 4 2 9 4.44 Above is just a miniature version of the file. In fact, considering the first column of the file that is 0 0 1 1 2, the numbers in actual go until 10442. This means my actual file looks like... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

5. UNIX for Dummies Questions & Answers

Merge two files with common IDs but unequal number of rows

Hi, I have two files that I would like to merge and think that there should be a solution using awk. The files look something like this: file 1 IDX1 IDY1 IDX2 IDY2 IDX3 IDY3 file 2 IDY1 dataA data1 IDY2 dataB data2 IDY3 dataC data3 Desired output IDX1 IDY1 dataA data1 IDX2 ... (5 Replies)
Discussion started by: katie8856
5 Replies

6. Shell Programming and Scripting

Shell Command to compare two xml lines while ignoring xml tags

I've got two different files and want to compare them. File 1 : HTML Code: <response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record... (1 Reply)
Discussion started by: Shaishav Shah
1 Replies

7. Shell Programming and Scripting

Compare two xml files while ignoring some xml tags

I've got two different files and want to compare them. File 1 : <response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record id="38,557"><columns><column><name>orge... (2 Replies)
Discussion started by: Shaishav Shah
2 Replies

8. Shell Programming and Scripting

Comparing two large unsorted csv files

Hi All, My requirement is to write a shell script to compare two large csv files. I've created sample files for explaining my problem i.e., a.csv and b.csv contents of files: ----------------- a.csv ------ Type,Memory (Kb),Location HD,Size (Mb),Serial # XT,640,D402,0,MG0010... (2 Replies)
Discussion started by: vasavi
2 Replies

9. Shell Programming and Scripting

Compare two xml files

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... (2 Replies)
Discussion started by: DeepaT
2 Replies

10. Shell Programming and Scripting

Splitting a single xml file into multiple xml files

Hi, I'm having a xml file with multiple xml header. so i want to split the file into multiple files. Sample.xml consists multiple headers so how can we split these multiple headers into multiple files in unix. eg : <?xml version="1.0" encoding="UTF-8"?> <ml:individual... (3 Replies)
Discussion started by: Narendra921631
3 Replies
STAG-AUTOSCHEMA(1p)					User Contributed Perl Documentation				       STAG-AUTOSCHEMA(1p)

NAME
stag-autoschema - writes the implicit stag-schema for a stag file SYNOPSIS
stag-autoschema -w sxpr sample-data.xml stag-autoschema -dtd sample-data.xml DESCRIPTION
Takes a stag compatible file (xml, sxpr, itext), or a file in any format plus a parser, and writes out the implicit underlying stag-schema stag-schema should look relatively self-explanatory. Here is an example stag-schema, shown in sxpr syntax: (db (person* (name "s" (address+ (address_type "s") (street "s") (street2? "s") (city "s") (zip? "s"))))) The database db contains zero or more persons, each person has a mandatory name and at least one address. The cardinality mnemonics are as follows: + 1 or more ? 0 or one * 0 or more The default cardinality is 1 ARGUMENTS
-p|parser FORMAT FORMAT is one of xml, sxpr or itext, or the name of a perl module xml assumed as default -dtd exports schema as DTD -w|writer FORMAT FORMAT is one of xml, sxpr or itext, or the name of a perl module, OR DTD The default is sxpr note that stag schemas exported as xml will be invalid xml, due to the use of symbols *, +, ? in the node names LIMITATIONS
not event based - memory usage becomes exhorbitant on large files; prepare a small sample beforehand perl v5.10.0 2008-12-23 STAG-AUTOSCHEMA(1p)
All times are GMT -4. The time now is 06:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy