Tag Archives: difference

icdiff: Visibility by default

I have just enough time this morning to scratch out a brief note about icdiff. We went through a lot of diff variants over the summer, and for every one of those there was probably a colorizing tool that could pick up the visual slack.

That might be the strongest point for icdiff: that fact that you get most of the best features of conventional tools like diff proper, plus a healthy degree of control available in tertiary colorizing tools.

2015-01-15-6m47421-icdiff-01 2015-01-15-6m47421-icdiff-02

I have two screenshots there because it might be important to you to know that, by default, icdiff is going to abbreviate its output to show changed areas and their context. This took me a minute to figure out, since my original file had 52 lines or so, but icdiff kept showing a much shorter output.

The --whole-file flag is what controls that, and there are quite a few other options worth mention. icdiff has a built-in head feature that constrains the input to the first x lines of each file, which may be useful as opposed to piping both files through head before handing them to icdiff.

Another point that might interest you is the --highlight flag, which colorizes the background field instead of the character shape itself. The author suggests it’s ugly but fast; it caught my attention because it was much easier to spot single-character changes with this.

icdiff is in AUR, but I didn’t find it in Debian. Users of either distro (or others) should be able to get it working from its git repo though, so feel free to try it out.

icdiff is a decent tool with some good features and might be more accessible to casual users — like myself — as opposed to the classic diff or simpler attempts to colorize it. It’s rare that I need a diff tool but I can see where this one would come in handy.

wdiff, cwdiff and dwdiff: Since I mentioned it. …

I just mentioned colordiff, but left out one thing it can do: colorize the output of wdiff. And what is wdiff, you say?

2014-07-27-lv-c5551-wdiff-colordiff

That should give you an idea. wdiff works in the same way as diff, but at a word-by-word level. If you look closely in the upper half of that image, the differences in lines of text are offset with brackets and curly braces.

That may be enough for you, but you have to admit that the second half, where the output was piped through colordiff, is much easier to scan. The man page says you should add -n to wdiff before sending it through colordiff, but as you can see there, it worked fine in that example.

wdiff works well with colordiff, but you might prefer cwdiff, as opposed to piping things through one another.

2014-07-27-lv-c5551-cwdiff

cwdiff does much of what wdiff + colordiff offers, and simplifies the process quite a bit. There are a few added options too, including one to subtract the color from the output — meaning you get pretty much what wdiff had originally.

By default, cwdiff’s output is simplified somewhat from what wdiff creates, or what wdiff produces through colordiff. It’s not necessarily better, but it is a tiny bit … different. πŸ™„

dwdiff is the last on the list that I feel obligated to mention at this point. By now, you’ll probably feel like dwdiff doesn’t really do anything that wdiff, colordiff, cwdiff or even just diff could handle.

2014-07-27-lv-c5551-dwdiff

dwdiff also plucks out differences between words of files, and has a -c flag to inject color into the output. The distinguishing point between dwdiff and the others, as I see it, is its ability to set specific delimiters while searching.

I couldn’t think of a good case example for that, and I searched around in hopes of finding something to test it. Nothing handy appeared though, and most examples for dwdiff seemed to generate the same output as wdiff alone or cwdiff might get you.

So the final questions become academic: First, do you want colorized output (say yes! say yes!); and second, do you need control over specific delimiters when comparing files?

If you answer yes to the first, cwdiff might be the best tool, although you can get the same results from wdiff alone if you have colordiff available. If you answer yes to the second, you’ll most likely want dwdiff regardless of your preference for color.

And if neither of those questions is important … well, then you can probably get through the day with just the original diff tool. No shame in that. πŸ˜‰

colordiff: A difference in color

Remember my unnatural predilection for anything in color? You have to admit I’m right on this point. After all, which would you rather look at?

2014-07-27-lv-c5551-colordiff

At the top, diff. At the bottom, colordiff. The choice should be an easy one.

The man page describes colordiff as a perl wrapper for diff, and that’s very true. As a matter of fact, it’s so tightly wound around diff that if you ask for colordiff --help, you get the output from diff --help. πŸ˜• And I know there’s no difference because I used colordiff to show the difference between diff --help and colordiff --help, and there was no difference. See what I mean? ❓

2014-07-27-lv-c5551-colordiff-diff-diff

Clear as mud.

colordiff has its own rc file, installed by default at /etc/colordiff in the Arch version. I would advise you to copy that into .colordiffrc, and customize the colors there, but if you’re just one of those weirdos who runs a black-on-white terminal emulator, you’d do just as well to copy /etc/colordiff-lightbg into your .colordiffrc file instead.

That’s about all I can think about with colordiff. It stays very tight to the original tool while still giving you a small measure of customization, and that will probably keep you happy in your pursuit of differences. πŸ˜‰

diff: Tools to show you what’s changed

Up front I should say that I had a nice post about diff and cmp and the other tools in diffutils ready, but by some freakish twist of fate, it seems to have vanished.

I blame no one for that, but it does mean that this post is a very abbreviated version — a mere shadow of its former glory.

In short, diff shows what’s different between two files, line by line. It sounds simpler than it is.

2013-10-17-lv-r1fz6-diff

As you can see, line by line, diff shows changes into or out of a file, as it compares to another.

If you’ve worked with diff, it was probably under the pretext of patches for code; that’s where I learned what little I know about it.

Technically diff only works with two files; diff3 should help you sift through three at a time.

At this point, you’re probably thinking that diff alone is only marginally useful, and obviously intended toward patching things. After all, it’s hardly readable except by experienced users.

To that end, I offer you sdiff, making life easy since … since … well, anyway:

2013-10-17-lv-r1fz6-sdiff

As you can see, sdiff does you the favor of flagging differing lines with pipe symbols. Much easier to absorb, for visual people … like me.

One last note: cmp comes with diff, but is quite different.

2013-10-17-lv-r1fz6-diff

Where diff is comparing lines of text, cmp is working byte-by-byte. I can only suggest that this might be useful if you’re looking for one or two different characters in two similar files — perhaps a data corruption issue, or something like it. I don’t have quite so much experience with cmp, as I do with diff … which isn’t saying much. πŸ™„

In closing I should mention that each of these has a laundry list of files and options, and a lot more ways to be put to use than what I show here.

But I think I hit the main points of the old post. I’ll dig around some more and see if I can dredge it up, but I have the feeling it’s lost to the ether. Such is life. 😐