Compare two folder structures and list files which exist in both, but are different I have a local working folder which mirrors part of a web server’s public folder. I usually work in the local copy and then auto-upload files to the server when saving. Trouble is, I’ve realised lately that a lot of files in my local files appear to be out of date, so whenever I save and upload a file, I’m potentially overwriting a newer version. This is obviously problematic, so I’d like to get all the out-of-date local files up to date.

The best way I can think of to do this is to download the entire public folder as it is and compare each file with my local copy, going manually through files with differences (by comparing them in Visual Studio Code). The public server folder has about 5GB of extra stuff that I don’t need (or want) in my local working folder, though, so I’d have to filter out the unwanted stuff first.

In other words, I’m looking for a way (GUI or terminal) to do the following:


Give two top-level directories as input
Iterate recursively through both directories and pick out files which exist in both (in the same relative location)
Compare each set of matched files and list the ones where the two files are not identical


Is there some reasonably non-complex way of doing this?
You can use diff for this after downloading the public folder:

diff -q -r working-folder public-folder


It will give you the list of files which are different, omit -q to also show a list of the actual differences.

To supress the listing of files only available in public-folder you can easily filter them via grep:

diff -q -r working-folder public-folder | grep -v '^Only in public-folder'


(make sure to replace the public-folder part with the real name in both occurances)