I usually use rsync
for this task:
rsync -nav --delete DIR1/ DIR2
BE VERY CAREFUL to always use the -n
, aka --dry-run
, option, or it will synchronize (change the contents of) the directories.
This will compare files based on file modification times and sizes... I think that's what you really want, or at least you don't mind if it does that? I got the sense that you just want it to happen faster, not that you need it to ignore the difference between file contents. If you do want it to not list differing files with identical names, I think the addition of the --ignore-existing
option will do that.
Also be aware that not putting a /
at the end of DIR1
will cause it to compare the directory DIR1
with the contents of DIR2
.
The output ends up being a bit verbose, but it will show you which files/directories differ. Files/directories present in DIR2
and not in DIR1
will be prefaced with the word deleting
.
For some situations, @slartibartfast's answer may be more appropriate, though you'll need to remove the -type d
option to enable the listing of non-directory files. rsync
will be faster if you've got a significant number of files/directories to compare.
By "directory structure", do you mean just the directory paths, or the paths of both directory and non-directory files? – intuited – 2010-07-22T06:26:36.497
Yes, folders and files. – Jonah – 2010-07-22T15:30:43.953
1In that case you should remove the
-type d
option from @slartibartfast's answer, or check out my answer. – intuited – 2010-07-22T17:52:56.030