[ACCEPTED]-showing differences within a line in diff output-word-diff

Accepted answer
Score: 13

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.

Score: 7

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)


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


enter image description here

Score: 5

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).

Score: 3

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.

Score: 2

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.

Score: 1

ccdiff is a convenient dedicated tool for the 14 task. Here is what an example may look like 13 with it:

ccdiff example output

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 or colordiff, 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