Skip to content | Skip to navigation
Hi,
I've stumbled over a problem that is kind of different as the topic might let you think: I want to compare two files and export the data that is equal to a file, NOT merging its differences to a new one!
I'm sure its quite simple - esp. under UNIX/linux - but my head's currently stuffed with lotsa OOP and usability issues, thus I dont get it working. Something like an inverted merge; instead of using the saved DIFF-file to merge both files you use it to find the similarities and extract them.
Does anybody know how to achieve this? I dont care if its Linux- or Windows-based; I've got all of that ;)
Thanks in advance,
cu, w0lf.
ps: story behind this: What I'm currently trying to do is to create a centralized, default stylesheet that shall be used as base for a small theme system.
Fuck off the 30 seconds posting limit!
Have 2 buffers, one for each file. Read each file byte by byte into their respective buffer, compare as you go throwing out the differences and keeping what's the same. Once the files are completely read into the buffers and both buffers are identical then write one of them out as a new file.
I hope that covers what you are asking, well as much as I understand what it is you are trying to do.
Sep 09, 2006 08:32 # 43441
ReallyCoolDude *** (7) has all the information you need...
Depending on whether you want to strip non-common lines or whether you want to strip out substrings within a line the solution could be different.
Check out this link for many solutions involving different scenarios - using awk, uniq, sort, comm, perl, and C++ to name a few.
Love is blind, but marriage is a real eye opener.