How to do diff like `git diff –word-diff` without git on Linux?

The 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
Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *