Search code examples
linuxbashshellunixdiff

Given two directory trees, how can I find out which files differ by content?


If I want find the differences between two directory trees, I usually just execute:

diff -r dir1/ dir2/

This outputs exactly what the differences are between corresponding files. I'm interested in just getting a list of corresponding files whose content differs. I assumed that this would simply be a matter of passing a command line option to diff, but I couldn't find anything on the man page.

Any suggestions?


Solution

  • Try:

    diff --brief --recursive dir1/ dir2/
    

    Or alternatively, with the short flags -qr:

    diff -qr dir1/ dir2/
    

    If you also want to see differences for files that may not exist in either directory:

    diff --brief --recursive --new-file dir1/ dir2/  # with long options
    diff -qrN dir1/ dir2/                            # with short flag aliases