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
8 comments // write a comment // comments off
Related stories
Comments
Re: Useful but Unknown Unix Tools: dwdiff better than wdiff + colordiff
Posted by: Axel Website: http://noone.org/blog Time: Sat, 17 Nov 2012 01:37 Indeed! Thanks for that comment!
Re: Useful but Unknown Unix Tools: dwdiff better than wdiff + colordiff
Posted by: Thomas Website: Time: Sat, 15 Dec 2012 12:03 Furthermore, you can configure what constitutes a word by passing a regex (--color-words=
), and even use .gitattributes and a diff driver config to apply it automatically to certain files. Plus, there are also some preconfigured word regexes for various programming languages. Re: Useful but Unknown Unix Tools: dwdiff better than wdiff + colordiff
Posted by: Anonymous Website: Time: Fri, 16 Nov 2012 03:05 There is also cwdiff: http://www.paulbarker.me.uk/dist/cwdiff-0.2.2.tar.gz
Re: Useful but Unknown Unix Tools: dwdiff better than wdiff + colordiff
Posted by: Axel Website: http://noone.org/blog Time: Sat, 17 Nov 2012 01:39 Interestingly that's neither its original site (which is https://code.google.com/p/cj-overlay/source/browse/cwdiff?repo=evergreens) nor is it the only program called "cwdiff". The first one I found while searching the web was at http://homepages.inf.ed.ac.uk/imurray2/compnotes/cwdiff/
Re: Useful but Unknown Unix Tools: dwdiff better than wdiff + colordiff
Posted by: me Website: Time: Mon, 21 Jan 2013 13:49 Is there a overview page for all "Useful but Unknown Unix Tools" articles?
A tag like "Useful but Unknown Unix Tools" would be cool.
Re: Useful but Unknown Unix Tools: dwdiff better than wdiff + colordiff
Posted by: Axel Website: http://noone.org/blog Time: Mon, 21 Jan 2013 14:00 There is. It's UUUT, because "Useful but Unknown Unix Tools" was too long for my taste.
See http://noone.org/blog/tags/UUUT
Your Comment
Spam Protection: To post a comment, you'll have to answer the following question: What is 42 minus 19?




Re: Useful but Unknown Unix Tools: dwdiff better than wdiff + colordiff
You can also use "git diff --no-index --color-words file1 file2" without needing a git repository.
Reply