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-05-2008
ragavhere ragavhere is offline
Registered User
  
 

Join Date: Apr 2008
Location: Chennai,India
Posts: 79
Comparing files exceeding 1.7GB

HI,

I have few files in two folders with the same name exceeding 2GB.I need to compare these files. These files are in the format

File1 in first folder
1|20080430|IA001|TREND DYNAMICS INC
2|20080430|IP001|AMERITAS LIFE INSURANCE CO
3|20080430|IP002|TRANSAMERICA LIFE INSURANCE CO

File1 in second folder
1|20080430|IA45|TREND DYNAMICS INC
2|20080430|IP001|AMERITAS LIFE INSURANCE CO


The files may be pipe or tab separated.

What i need to do here is to sort both the files, then compare. But the problem here is since the file exceeds 2GB sort command wont work and the diff command wont work. The comparison has to be line by line and field to field. The output should be in this format

For lines from files in first folder i need to indicate it by appending "From Test1" to the beginning of mismatching line like this

From Test1 - 1|20080430|IA001|TREND DYNAMICS INC

For lines from files in second folder i need to indicate it by appending "From Test2" to the beginning of mismatching line like this

From Test2 - 1|20080430|IA45|TREND DYNAMICS INC
And if a line found in file 1 of first folder is not found in file 1 of second folder then print that line alone to my output file


Hence my Final output should be like

From Test1 - 1|20080430|IA001|TREND DYNAMICS INC
From Test2 - 1|20080430|IA45|TREND DYNAMICS INC

From Test1 - 3|20080430|IP002|TRANSAMERICA LIFE INSURANCE CO

Is there a way to do it?

Last edited by ragavhere; 06-05-2008 at 05:18 PM..