Skip to main content
4 of 4
deleted 13 characters in body
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Using wdiff:

$ wdiff -3 a.txt b.txt

======================================================================
 [-b-] {+B+}
======================================================================

The -3 or ---no-common option will remove words that are common between the two files and only show the differences.

The ===... banner (and empty lines) may be removed with grep:

$ wdiff -3 a.txt b.txt | grep -vx '=*'
 [-b-] {+B+}

wdiff may also read unified diff data if you give it the -d or --diff-input option, for example from git:

git diff somefile | wdiff -d -3

Although wdiff is not a POSIX tool, it is commonly available.

Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k