ceiling cat
ceiling cat

Reputation: 5701

command line recursive word-based diff?

is there a command line program that gives recursive word-based diff (on 2 directories)?

diff -u is recursive, but it doesn't do word by word comparison. wdiff and dwdiff does word based diff but there are not built-in options for recursive diff.

I would like to pipe the result to colordiff so a program that generates output that colordiff understands would be especially useful. Any suggestions? Thanks!

CC

Upvotes: 14

Views: 2299

Answers (1)

Michael W
Michael W

Reputation: 296

Git can do it and output color:

The following often works:

git diff --color-words path1 path2

but in general you may need to do

git diff --no-index --color-words path1 path2

Neither file even needs to be in a git repository!

--no-index is needed if you and the paths are in a git working tree. It can be elided if you or one of the files are outside a git working tree.

Manpage: https://git-scm.com/docs/git-diff/1.8.5 (and later...)

git diff --no-index [--options] [--] […​]

This form is to compare the given two paths on the filesystem. You can omit the --no-index option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git.

Upvotes: 28

Related Questions