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.
Timmmm
  • 586
  • 5
  • 17

3 Answers3

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.

Timmmm
  • 586
  • 5
  • 17
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:

ronezone
  • 31
  • 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}[^ ]'