This StackOverflow answer has an image of KDiff3 highlighting intra-line differences. Does someone know of a tool which can show the same (ex, via color) on the command line?
Another way to think of this is wanting to diff each difference in a patch file.
I tried all the tools I found: wdiff, dwdiff, kdiff3, vimdiff to show the difference between two long and slightly different lines. My favourite is
diff-highlight
(part of git contrib)Installation
On Ubuntu, you probably already have it as part of git contrib (installed within the
git
deb package). Copy or link it into your ~/bin folder from/usr/share/doc/git/contrib/diff-highlight/diff-highlight
Usage example
Result:
I don't know if this is sufficiently command line for your purpose, but vimdiff can do this (even does colour). See for example the image in this related question.
I had a similar problem and wanted to avoid using
vimdiff
. I founddwdiff
(which is available in Debian) to have several advantages overwdiff
.The most useful feature of
dwdiff
is that you can customise the delimiters with-d [CHARS]
, so it's useful for comparing all kinds of output. It also has color built in with the-c
flag.Another intuitive way to see all word-sized differences (though not side-by-side) is to use
wdiff
together withcolordiff
(you might need to install both). An example of this would be:You can optionally pipe this into
less -R
to scroll through the output (-R
is used to show the colors inless
).You might be able to use
colordiff
for this.In their man page:
I haven't tested it, but the side-by-side output (as produced by
diff -y file1 file2
) might give you the equivalent of in-line differences.