I enjoy looking for lightweight alternatives to GNU core utilities. Some of the BSD tools make great alternatives. I’ve recently been looking into various diff utility implementations. Would be curious if anyone would be interested in discussing what they would like in a diff utility and which difference algorithms they prefer. I just wrote a short blog post summarizing what I’ve dug up so far and listing some of the alternatives to GNU diffutils such as BSD diff, Busybox diff and others.
Yes, interested. I find normal gnu diff quite a challenge… I guess that is because it was designed for its output to be readable by other utilities.
I have not looked at other diffs… I swallowed my CLI pride and resorted to meld.
I can look at the meld outout and get a picture of all the substitutions required to move from one file to the other.
Diff, on the other hand, tends to become unreadable after the first substitution of an unequal number of lines.
I only ever use diff(meld) when programming. Data files dont tend to have random edits like source files.
Hi Laura, ![]()
there´s also the cmp command.
I´ve used it several times in the past, especially with the parameters -s, -l and -b.
tldr cmp
cmp
Compare two files byte by byte.
More information: https://www.gnu.org/software/diffutils/manual/diffutils.html#Invoking-cmp.
- Output char and line number of the first difference between two files:
cmp path/to/file1 path/to/file2
- Output info of the first difference: char, line number, bytes, and values:
cmp [-b|--print-bytes] path/to/file1 path/to/file2
- Output the byte numbers and values of every difference:
cmp [-l|--verbose] path/to/file1 path/to/file2
- Compare files but output nothing, yield only the exit status:
cmp [-s|--quiet] path/to/file1 path/to/file2
It´s great for comparing non-txt files.
Other than that I´ve been using diff and meld as well, like @nevj does.
Many greetings from Rosika ![]()
I use diff with diffh. Using diff by itself, I find it most useful for creating patches when I’m building and modifying FLOSS. I use a modified version of patch that’s used by many BSD systems. My modifications are mainly to make it port easier to other platforms not to change how it works. The diffh program outputs unidiff changes side by side in a readable format in HTML. So, all you need is a browser and you can view the changes more easily. It’s a lightweight alternative to meld. It’s also very easy to port to various platforms even FreeDOS. I’ve been exploring some of the algorithms used in various diff implementations. Many use older algorithms that aren’t optimized for speed like the BSD version of diff. The GNU diff program uses the newer Myers’ algorithm. Am just now reading about the histogram algorithm used in programs like git. From what I’ve read, it’s as efficient as Myers’ and it comes up with nicer groupings in its solutions. Seems every diff algorithm can up with a different solution to the same problem. There can be more than one optimal solution to display but some are more logical and readable than others. I’m very surprised that outside of version control utilities none of the diff implementations seem to have made use of the histogram diff algorithm. Was thinking of experimenting with a Myers’ based solution but a histogram algorithm with Myers’ fallback sounds like a better way to go.
For programming (text), I find “vim -d file1 file2” to do just fine.