Reputation: 2795
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.
Upvotes: 26
Views: 21315
Reputation: 6271
Another intuitive way to see all word-sized differences (though not side-by-side) is to use wdiff
together with colordiff
(you might need to install both). An example of this would be:
wdiff -n {file-A} {file-B} | colordiff
You can optionally pipe this into less -R
to scroll through the output (-R
is used to show the colors in less
).
Upvotes: 5
Reputation: 1
icdiff is another option. It can be used standalone, or as a Git command (git icdiff
).
Upvotes: 0
Reputation: 251
ccdiff
is a convenient dedicated tool for the task. Here is what an example may look like with it:
By default, it highlights the differences in color, but it can be used on a console without color support too.
The package is included in the main repository of Debian:
ccdiff is a colored diff that also colors inside changed lines.
All command-line tools that show the difference between two files fall short in showing minor changes visuably useful. ccdiff tries to give the look and feel of
diff --color
orcolordiff
, but extending the display of colored output from colored deleted and added lines to colors for deleted and addedd characters within the changed lines.
Upvotes: 4
Reputation: 29473
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)
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
cat tmp.diff | diff-highlight | colordiff
Result:
Upvotes: 12
Reputation: 1733
I had a similar problem and wanted to avoid using vimdiff
. I found dwdiff
(which is available in Debian) to have several advantages over wdiff
.
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.
Upvotes: 3
Reputation: 70142
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.
Upvotes: 17
Reputation: 258128
You might be able to use colordiff
for this.
In their man page:
Any options passed to colordiff are passed through to diff except for the colordiff-specific option 'difftype', e.g.
colordiff --difftype=debdiff file1 file2
Valid values for 'difftype' are: diff, diffc, diffu, diffy, wdiff, debdiff; these correspond to plain diffs, context diffs, unified diffs, side-by-side diffs, wdiff output and debdiff output respectively. Use these overrides when colordiff is not able to determine the diff-type automatically.
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.
Upvotes: 2