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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Comparing two files and outputting

Reply to Message Icon

Name: james_warren
Date: March 7, 2007 at 05:23:01 Pacific
OS: Unix AIX
CPU/Ram: 2000/512
Product: 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!




Sponsored Link
Ads by Google

Response Number 1
Name: thepubba1
Date: March 7, 2007 at 07:23:41 Pacific
Reply:

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...


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Comparing two files and outputting

compare two files and diff file wil www.computing.net/answers/unix/compare-two-files-and-diff-file-wil/7363.html

comparing two files www.computing.net/answers/unix/comparing-two-files/8256.html

compare two files field string www.computing.net/answers/unix/compare-two-files-field-string/8078.html