The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-04-2008
ragavhere ragavhere is offline
Registered User
  
 

Join Date: Apr 2008
Location: Chennai,India
Posts: 79
Cool Comparing files enen when they are not in order

Hi,

I have two master files which contain the information for many jobs like this

Job no:1 a b c d
Job no:1 d e g h

Job no:2 t j s h
Job no:2 t j s h

I have written a script to pick up all the information for Job no:1 from file1 and put that to a temporary file and do the same from file2 and put it to a temporary file. Then i will compare this two temporary files using diff. If they dont match print the information for that Job from both the master files in to one output file.After the comparison is done for one job,i will read the information for the next job and compare. Here the problem is if the order of the information for Job number changes like this

In file1 i have

Job no:1 a b c d
Job no:1 d e g h

In file 2 i have

Job no:1 d e g h
Job no:1 a b c d
Here diff would fail even though there is no mismatch except the order has changed which is not an issue. Is there any other way to read the information for a particular job from file one and then print out that to a file. Then do the same for the information from file2.Then compare.If they are same leave it else print information from both the master files to the output file.

Last edited by ragavhere; 06-04-2008 at 05:07 PM.. Reason: Question not clear