How to do diff like `git diff –word-diff` without git on Linux?
Posted on In QAThe result of git by git diff --word-diff
is great. But how to do diff like git diff --word-diff
without git on Linux? The plain diff
command on Linux seems not accept options like --word-diff
.
The wdiff
is for word-diff:
wdiff program
is a front end to diff for comparing files on a word per word basis. A word is anything between whitespace.
$ wdiff file1 file2
Bonus: colordiff is a wrapper for ‘diff’. colordiff is written in Perl and produces the same output but with pretty ‘syntax’ highlighting.
$ wdiff file1 file2 | colordiff
or
$ wdiff file1 file2 | colordiff | less -R
Not exactly what you’re asking for, but you could pipe plain
diff
output throughriff
:Riff will highlight what words were added / removed in the diff, which might be exactly what you want. Riff also integrates with
git
and pages its result just likegit diff
.Get it here: .
Disclaimer: I’m the
riff
author.Thanks for this! I executed and added this line to my
~/.bashrc
Now I can do:
difff file1 file2
Link to riff since it was broken in my last post, same comment still applies:
https://github.com/walles/riff