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.

The best I have so far is:

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

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.

| improve this answer | |
  • 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 Jan 26 at 23:34
  • They don't. Read the link. – Timmmm Jan 27 at 10:21

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}[^ ]' 
| improve this answer | |
  • I mentioned the grep solution in my answer but a regex is too slow. – Timmmm Jul 28 '18 at 17:29

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.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.