dwdiff

word-by-word file comparison

TLDR

Compare two files word by word
$ dwdiff [file1.txt] [file2.txt]
Use color output
$ dwdiff -c [file1.txt] [file2.txt]
Show only the changes, suppressing words common to both files
$ dwdiff -3 [file1.txt] [file2.txt]
Show line numbers
$ dwdiff -L [file1.txt] [file2.txt]
Ignore case differences
$ dwdiff -i [file1.txt] [file2.txt]
Treat punctuation as delimiters so words are split more finely
$ dwdiff -P [file1.txt] [file2.txt]
Print statistics about how much changed
$ dwdiff -s [file1.txt] [file2.txt]
Page the diff with less-style highlighting
$ dwdiff -l [file1.txt] [file2.txt] | less -R

SYNOPSIS

dwdiff [options] file1 file2

DESCRIPTION

dwdiff compares files word-by-word rather than line-by-line, making it easier to spot small changes in prose or documentation. It highlights deleted words (from the first file) and inserted words (in the second file).The tool is particularly useful for comparing text documents, translations, or any content where line-based diffs produce confusing output. It shows exactly which words changed between versions.

PARAMETERS

-c[spec], --color[=spec]

Color the output. An optional spec overrides the delete and insert colors.
-l, --less-mode
Use overstriking (underline for deletions, bold for insertions), suitable for piping to less -R.
-L[width], --line-numbers[=width]
Show line numbers at the start of each line.
-s, --statistics
Print word counts and change percentages when done.
-i, --ignore-case
Ignore differences in case when comparing words.
-I, --ignore-formatting
Ignore formatting changes such as bold or underline markup.
-d chars, --delimiters=chars
Characters to treat as word delimiters.
-P, --punctuation
Use punctuation characters as delimiters.
-W chars, --white-space=chars
Characters to treat as whitespace.
-1, --no-deleted
Suppress words deleted from the first file.
-2, --no-inserted
Suppress words inserted in the second file.
-3, --no-common
Suppress words common to both files, leaving only the changes.
-C num, --context=num
Show num lines of context around each change.
-A algo, --algorithm=algo
Comparison algorithm: best, normal or fast.
-w string, --start-delete=string
String marking the start of deleted text (default `[-`).
-x string, --stop-delete=string
String marking the end of deleted text (default `-]`).
-y string, --start-insert=string
String marking the start of inserted text (default `{+`).
-z string, --stop-insert=string
String marking the end of inserted text (default `+}`).
--diff-input
Read unified diff output instead of two files.
--wdiff-output
Produce wdiff-compatible output.

OUTPUT FORMAT

$ [-removed-] {+added+}
Deleted text is shown in brackets with minus, inserted text in braces with plus.

INSTALL

sudo apt install dwdiff
brew install dwdiff
nix profile install nixpkgs#dwdiff

CAVEATS

Best suited for prose, not code. Large files may be slow to process. Word boundaries depend on delimiter settings. May need adjustment for non-English text or special characters.

HISTORY

dwdiff was written by G.P. Halkes as an improved alternative to the older wdiff utility. It provides better handling of Unicode, color output, and more flexible word delimiting options.

SEE ALSO

wdiff(1), diff(1), colordiff(1), vimdiff(1)

RESOURCES

Homepage