Friday·16·November·2012
Useful but Unknown Unix Tools: dwdiff better than wdiff + colordiff //at 01:18 //by abe
A year ago I wrote in Useful but Unknown Unix Tools: How wdiff and colordiff help to choose the right Swiss Army Knife about using wdiff and colordiff together. Colordiff’ed wdiff output looks like this:
$ wdiff foobar.txt barfoo.txt | colordiff [-foo-]bar fnord gnarz hurz quux bla {+foo+} fasel
But if you have colour, why still having these hard to read wdiff markers still in the text?
There exists a tool named dwdiff which can do word diffs in colour without
textual markers and with even less to type (and without being
git diff --color-words
;-). Actually it looks like
git diff --color-words
, just without the git:
$ dwdiff -c foobar.txt barfoo.txt foo bar fnord gnarz hurz quux bla foo fasel
Another cool thing about dwdiff (and its name giving feature) is that you can defined what you consider whitespace, i.e. which character(s) delimit the words. So lets do the example above again, but this time declare that “f” is considered the only whitespace character:
$ dwdiff -W f -c foobar.txt barfoo.txt foo bar bar fnord gnarz hurz quux bla foo fasel
dwdiff can also show line numbers:
$ dwdiff -c -L foobar.txt barfoo.txt 1:1 foo bar fnord 2:2 gnarz hurz quux 3:3 bla foo fasel $ dwdiff -c -L foobar.txt quux.txt 1:1 foo bar fnord 1:2 foobar floedeldoe 2:3 gnarz hurz quux 3:4 bla foo fasel
(coloured shell screenshots by aha)
Tagged as: aha, colordiff, dwdiff, git, UUUT, wdiff
// show without comments // write a comment