10

I have two ~1 GB files that I want to do a side by side diff of. Solutions I have tried:

  • diff - Works quickly but doesn't output side-by-side.
  • diff -y or sdiff - This outputs side-by-side but it outputs the entire file - not just the changes, so they are impossible to find.
  • icdiff - Just too slow (it's written in Python so no surprise there).
  • ydiff - Not actually tried but it is also written in Python so I assume it will also be very slow.
  • KDiff3 - Crashed.
  • Xcode FileMerge - Too slow (gave it a few minutes of non-responsiveness).
  • Beyond Compare - Max 500MB limit.
  • Meld - Made a little progress but far too slow to be useful.
  • vimdiff - Loads the files successfully and actually displays a side-by-side diff, but the colour scheme makes it unreadable, and normal things that you'd expect from a sane program do not work, e.g. pressing up to scroll up.
2

3 Answers 3

6

The best I have so far is:

diff -y --suppress-common-lines --speed-large-files file1 file2

Use --width=200 to control the width.

However unfortunately that doesn't show you any context lines.

I found another solution using grep which seemed ok but it uses a regex and is just too slow.

2
  • This is GNU grep. I'd check it the various context flags work (-c, -u), but I'd guess that clashes with --supress-common-lines
    – vonbrand
    Commented Jan 26, 2020 at 23:34
  • They don't. Read the link.
    – Timmmm
    Commented Jan 27, 2020 at 10:21
3

vimdiff worked great for me in 'MINGW64' [mintty 2.0.3(x86_64-pc-msys © 2015 by Andy Koppe) terminal that installed with my Vagrant install following VaryingVagrantVagrants instructions.]

Ctrl+f to navigate forward; Ctrl+b to navigate backward/up :q-Enter and again :q-Enter (to close the 2nd file if you've compared two files as below.)

![viminfo output example]2

Arrow keys also function as well as your mouse-wheel; just be patient to let it finish loading... and you can control the color scheme in your 'MINGW64' window options as well as the .minttyrc file (see here for more info):

![MINGW64/mintty options]4 I made my cursor orange, blinking, so it's easier to locate.

2:

0

If you want context, you can pipe the (unsuppressed) output of sdiff (or diff -y) through egrep with before (-B) and after (-A) context:

sdiff -H -t file1 file2 | egrep -B1 -A1 '^.{64}[^ ]' 

The -t and the .{64} are there to get to the midway point of the default 130 character width (expanding tabs in the output so they don't mess up the count). You can specify a shorter width, but you'd have to adjust that offset accordingly:

sdiff -H -w 80 -t file1 file2 | egrep -B1 -A1 '^.{39}[^ ]' 
1
  • I mentioned the grep solution in my answer but a regex is too slow.
    – Timmmm
    Commented Jul 28, 2018 at 17:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .