==== ignore subdirectories ==== One way is to call diff without the --recursive (-r) option and use grep to filter out the unwanted messages: % diff dir1 dir2 | grep -v "^Only in " or % diff -q dir1 dir2 | grep -v "^Only in " See https://stackoverflow.com/questions/30446490/diff-only-compare-files-and-ignore-subdirectories/ for some sample tests using this idea. ==== 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: * ''git diff --no-index --color-words -- foo bar'' - to diff word by word * ''git diff --no-index --color-words=. -- foo bar'' - to diff character by character ==== 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 ==== tags | ignore line endings diff --strip-trailing-cr file1 file2 $ diff --help | grep -i strip --strip-trailing-cr strip trailing carriage return on input Ref:- https://stackoverflow.com/questions/40974170/how-can-i-ignore-line-endings-when-comparing-files