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.


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:


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.


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. šŸ˜