[ACCEPTED]-showing differences within a line in diff output-word-diff
I don't know if this is sufficiently command 3 line for your purpose, but vimdiff can do this 2 (even does colour). See for example the 1 image in this related question.
I tried all the tools I found: wdiff, dwdiff, kdiff3, vimdiff 6 to show the difference between two long 5 and slightly different lines. My favourite 4 is diff-highlight
(part of git contrib)
- it supports diff format - great advantage over tools requiring two files like (dwdiff), e.g. if you need to visualize the output of unit tests
- it highlights with black+white or with color if you connect it to colordiff
- highlights characterwise - helpful for comparing long lines without spaces (better than wdiff)
Installation
On Ubuntu, you 3 probably already have it as part of git 2 contrib (installed within the git
deb package).
Copy 1 or link it into your ~/bin folder from /usr/share/doc/git/contrib/diff-highlight/diff-highlight
Usage example
cat tmp.diff | diff-highlight | colordiff
Result:
Another intuitive way to see all word-sized 6 differences (though not side-by-side) is 5 to use wdiff
together with colordiff
(you might need to 4 install both). An example of this would 3 be:
wdiff -n {file-A} {file-A} | colordiff
You can optionally pipe this into less -R
to 2 scroll through the output (-R
is used to show 1 the colors in less
).
I had a similar problem and wanted to avoid 6 using vimdiff
. I found dwdiff
(which is available in 5 Debian) to have several advantages over 4 wdiff
.
The most useful feature of dwdiff
is that you 3 can customise the delimiters with -d [CHARS]
, so it's 2 useful for comparing all kinds of output. It 1 also has color built in with the -c
flag.
You might be able to use colordiff
for this.
In their 12 man page:
Any options passed to colordiff are passed 11 through to diff except for the colordiff-specific 10 option 'difftype', e.g.
colordiff --difftype=debdiff file1 file2
Valid values for 9 'difftype' are: diff, diffc, diffu, diffy, wdiff, debdiff; these 8 correspond to plain diffs, context diffs, unified 7 diffs, side-by-side diffs, wdiff output 6 and debdiff output respectively. Use these overrides 5 when colordiff is not able to determine 4 the diff-type automatically.
I haven't 3 tested it, but the side-by-side output (as 2 produced by diff -y file1 file2
) might give you the equivalent 1 of in-line differences.
ccdiff
is a convenient dedicated tool for the 14 task. Here is what an example may look like 13 with it:
By default, it highlights the differences 12 in color, but it can be used on a console 11 without color support too.
The package is 10 included in the main repository of Debian:
ccdiff 9 is a colored diff that also colors inside 8 changed lines.
All command-line tools that 7 show the difference between two files fall 6 short in showing minor changes visuably 5 useful. ccdiff tries to give the look and 4 feel of
diff --color
orcolordiff
, but extending the display 3 of colored output from colored deleted and 2 added lines to colors for deleted and addedd 1 characters within the changed lines.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.