Stoppt die Vorratsdatenspeicherung! Jetzt klicken &handeln! Willst du auch an der Aktion teilnehmen? Hier findest du alle relevanten Infos und Materialien:
Jump to menu and information about this site.

Friday·16·November·2012

Useful but Unknown Unix Tools: dwdiff better than wdiff + colordiff //at 01:18 //by abe

from the colordiff-revisited dept.

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)

Comments

Re: Useful but Unknown Unix Tools: dwdiff better than wdiff + colordiff

Posted by: Anonymous
Website: 
Time: Fri, 16 Nov 2012 02:25

You can also use "git diff --no-index --color-words file1 file2" without needing a git repository.

Reply

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!

Reply

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.

Reply

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

Reply

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/

Reply

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.

Reply

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

Reply

Re: Useful but Unknown Unix Tools: dwdiff better than wdiff + colordiff

Posted by: me
Website: 
Time: Mon, 21 Jan 2013 14:02

Thank you!

Reply

Your Comment

Spam Protection: To post a comment, you'll have to answer the following question: What is 42 minus 19?

Name:
URL or E-Mail: [http://... or mailto:you@example.com] (optional)
Title: (optional)
Spam Protection Answer:
Comment:

Tag Cloud

2CV, aha, Apache, aptitude, ASUS, Automobiles, autossh, Berlin, bijou, Blogging, Blosxom, Blosxom Plugin, Browser, BSD, CDU, Chemnitz, Citroën, CLI, CLT, Conkeror, CX, deb, Debian, Doofe Parteien, E-Mail, eBay, EeePC, Emacs, Epiphany, Etch, ETH Zürich, Events, Experimental, Firefox, Fläsch, FreeBSD, FVWM, Galeon, Gecko, git, GitHub, GNOME, GNU, GNU Coreutils, GNU Screen, Google, GPL, grep, grml, gzip, Hacks, Hardware, Heise, HTML, identi.ca, IRC, irssi, Jabber, JavaShit, Kazehakase, Lenny, Liferea, Linux, LinuxTag, LUGS, Lynx, maol, Meme, Microsoft, Mozilla, Music, mutt, Myon, München, nemo, Nokia, nuggets, Open Source, Opera, Pentium I, Perl, Planet Debian, Planet Symlink, Quiz, Rant, ratpoison, Religion, RIP, Sarcasm, Sarge, Schweiz, screen, Shell, Sid, Spam, Squeeze, SSH, Stöckchen, SuSE, Symlink, Symlink-Artikel, Tagging, Talk, taz, Text Mode, ThinkPad, Ubuntu, USA, USB, UUUCO, UUUT, VCFe, Ventilator, Vintage, Wahlen, Wheezy, Wikipedia, Windows, WML, Woody, WTF, X, zsh, Zürich, ÖPNV

Calendar

 2012 
Months
Nov
 November 
Mo Tu We Th Fr Sa Su
     
16
   

Tattletale Statistics

Blog postings by posting time
Blog posting times this month



Search


Advanced Search


Categories


Recent Postings

0 most recent of 0 postings total shown.


Recent Comments

Hackergotchi of Axel Beckert

About...

This is the blog or weblog of Axel Stefan Beckert (aka abe or XTaran) who thought, he would never start blogging... (He also once thought, that there is no reason to switch to this new ugly Netscape thing because Mosaïc works fine. That was about 1996.) Well, times change...

He was born 1975 at Villingen-Schwenningen, made his Abitur at Schwäbisch Hall, studied Computer Science with minor Biology at University of Saarland at Saarbrücken (Germany) and now lives in Zürich (Switzerland), working at the IT Support Group (ISG) of the Departement of Physics at ETH Zurich.

Links to internal pages are orange, links to related pages are blue, links to external resources are green and links to Wikipedia articles, Internet Movie Database (IMDb) entries or similar resources are bordeaux. Times are CET respective CEST (which means GMT +0100 respective +0200).


RSS Feeds


Identity Archipelago


Picture Gallery


Button Futility

Valid XHTML Valid CSS
Valid RSS Any Browser
GeoURL
This content is licensed under a Creative Commons License (SA 3.0 DE). Some rights reserved. Hacker Emblem
Get Mozilla Firefox! Powered by Linux!
Typed with GNU Emacs Listed at Tux Mobil
XFN Friendly Button Maker

Blogroll

Blog or not?


People I know personally


Other blogs I like or read


Independent News


Interesting Planets


Web comics I like and read

Stalled Web comics I liked


Blogging Software

Blosxom Plugins I use

Bedside Reading

Just read

  • Bastian Sick: Der Dativ ist dem Genitiv sein Tod (Teile 1-3)
  • Neil Gaiman and Terry Pratchett: Good Omens (borrowed from Ermel)

Currently Reading

  • Douglas R. Hofstadter: Gödel, Escher, Bach
  • Neil Gaiman: Keine Panik (borrowed from Ermel)

Yet to read

  • Neil Stephenson: Cryptonomicon (borrowed from Ermel)

Always a good snack

  • Wolfgang Stoffels: Lokomotivbau und Dampftechnik (borrowed from Ermel)
  • Beverly Cole: Trains — The Early Years (getty images)

Postponed