2

Possible Duplicate:
Linux: Compare Directory Structure Without Comparing Files

I am diff-ing two folder trees, but it takes a long time because it is diff-ing the files themselves. I just want to know what folders/files are in one tree and not the other.

What is the best way to do this?

Jonah
  • 955

1 Answers1

7

Use find to list the files in each tree, sort them, then use diff or comm for comparison. The little-known comm command is a specialized file comparison tool that just distinguishes lines appearing only in the first file, lines appearing only in the second file and lines appearing in both files.

(cd /some/dir1 && find . | sort >/tmp/dir1.find)
(cd /where/dir2 && find . | sort >/tmp/dir2.find)
# Show the files that are in dir1 but not in dir2
comm -23 /tmp/dir1.find /tmp/dir2.find
# Show the files that are in dir2 but not in dir1
comm -13 /tmp/dir1.find /tmp/dir2.find