0

I would like to compare two large files that are not close to 1Gb in size.

Kompare crashes when the files load is large. I configured Kompare as in the photo below:

Trying to configure it for large files

I would like to present the differences in a way that Kompare does (i.e. clear and showing with colors and lines), manageable for people who are not familiar with Terminal.

I have also tried using the command:

diff --speed-large-files a.file b.file

As suggested here:

Is there a way to dump the output of diff into a file, so it can be read later by another program.

Mc Jorch
  • 3
  • 2

1 Answers1

1

Is there a way to dump the output of diff into a file, so it can be read later by another program?

Yep!

diff --speed-large-files a.file b.file > diffoutput

This creates a file called diffoutput, and writes the output of diff to it.

I would like to present the differences in a way that Kompare does (i.e. clear and showing with colors and lines), manageable for people who are not familiar with Terminal.

I don't think Kompare will work for this purpose. (Or, at least not directly.) I tried to diff two 3MB files, and it required 150 MB of memory. I assume that if I tried to diff two 1GB files, it would require about 50GB.

Here some ideas:

  • Split the files up. split -l 5000 filename can split a file named filename into 5000 line chunks.
  • Remove unimportant lines. Hypothetically, if you only cared about lines that had FOOBAR in them, you could run grep FOOBAR input > output and get only the lines that contained FOOBAR.
  • Use some shell. This command:

    colordiff --suppress-common-lines -y file1.ext file2.ext | aha > test.html
    

    will diff two lines; apply coloring for the differing lines; remove common lines; display them side-by-side; and create an HTML file that can be opened in a web browser.

Nick ODell
  • 2,498
  • 2
  • 20
  • 28
  • That did the trick, thanks! I really appreciate it. Note: Doing some research, I have found a program called Beyond Compare that does almost the same thing with large files as the solution you've proposed. – Mc Jorch Sep 16 '18 at 22:38
  • Chopping up the files will split some matches, and make others dissappear (into different pieces). – vonbrand Jan 26 '20 at 23:28