Table of Contents

diff word by word

git diff --word-diff --no-index -- foo bar

or

git diff -U0 --word-diff --no-index -- foo bar

You can run this command even if the files are not part of a git repository.

Ref:- https://unix.stackexchange.com/a/330807/198064

Related commands:

head and diff

To diff headers of two files without creating any temporary files

% diff <(head -n 1 foo.20170102) <(head -n 1 foo.20170104)

ignore newline endings

diff --strip-trailing-cr file1 file2