Created
February 12, 2011 02:13
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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