Computing.Net > Forums > Unix > Comparing two files and outputting

Comparing two files and outputting

Reply to Message Icon

Original Message
Name: james_warren
Date: March 7, 2007 at 05:23:01 Pacific
Subject: Comparing two files and outputting
OS: Unix AIX
CPU/Ram: 2000/512
Model/Manufacturer: Dell
Comment:

Hello all I hope someone can help! It would be much appreciated! What I need to do is compare a load of numbers in file1 to a load of numbers in file2. Each number is on a seperate line so

file1 would look like:
0000001
0000006
0000009

file2:
0000002
0000003
0000004
0000005
0000006

Also note the numbers are in order.

If I was using vb or any normal programming language I would do this with a nested loop but I can't find an efficient was of reading through the lines in a shellscript.

So basically what it should do is look for the first line in file1 in file2 goign through sequencially until it's greater than the value in file1 and keeping the pointer at that line and then incrementing again for line 2 then line 3 ect...

I think this should be the most efficient way of doing this but as I'm new to .sh and .ksh I'm finding it a bit tricky. The reason it needs to be effecient is that the files are HUGE.

Also when a match is found it should output the result to file3.

Many thanks in advance peeps!



Report Offensive Message For Removal


Response Number 1
Name: thepubba1
Date: March 7, 2007 at 07:23:41 Pacific
Subject: Comparing two files and outputting
Reply: (edit)

An example of what you are trying to do was given in this forum a couple of weeks ago.


http://www.computing.net/unix/wwwbo...


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Comparing two files and outputting 

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge