in reply to Re: Compare large files
in thread Compare large files

If you can't use any command line tools (such as comm as sugested), sort both files (using the sort utility) and read lines from both files, comparing them on the fly. This will enable you to compare arbitrarily large files with minimal overhead.

Replies are listed 'Best First'.
Re^3: Compare large files
by tilly (Archbishop) on Jul 10, 2009 at 04:38 UTC
    Be warned. In Linux you generally should set the environment variable LC_ALL to C before using sort. Otherwise its idea of sorted order does potentially inconvenient things like:
    1,10 11,1 1,123
    (What? You were expecting all of the things with ID 1 to be grouped together? Silly programmer, read the documentation!)
Re^3: Compare large files
by JavaFan (Canon) on Jul 09, 2009 at 20:18 UTC
    If you can't use any command line tools, you can't use sort either....
      You can, however, use File::Sort. Though for one reason or another whenever I've needed to sort data and couldn't use the sort utility, I've always rolled my own.

      Sorry - I wasn't too precise on that one. What I meant was if the command line tools for file diff and comparison wasn't sufficient, use sort and something handwritten as specified.