Skip to content

Instantly share code, notes, and snippets.

@adeel
Created February 12, 2011 02:13
Show Gist options
  • Save adeel/823414 to your computer and use it in GitHub Desktop.
Save adeel/823414 to your computer and use it in GitHub Desktop.
How to get a word-by-word diff of two text files, and format it as html
#!/bin/sh
FILE1=$1
FILE2=$2
# http://www.gnu.org/software/wdiff/
wdiff -w "<span style='color:red; text-decoration: line-through;'>" \
-x "</span>" \
-y "<span style='color:green'>" \
-z "</span>" \
$FILE1 $FILE2 > _tmpdiff.html
# replace newlines with <br>s
perl -i -p -e 's/\n/\<br\>/' _tmpdiff.html
cat _tmpdiff.html
rm _tmpdiff.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment