Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

marked as duplicate by Dennis Williamson, harrymc, random Jul 26 '10 at 4:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Possible duplicate of… – coneslayer Jul 23 '10 at 19:15
That was comparing, this is diff-ing. – Jonah Jul 23 '10 at 19:19
@Jonah - are you asking how to do it, specifically with diff, when the other question was open to other tools and commands? – Gnoupi Jul 23 '10 at 19:22
Using diff would be good, but if it can't do it other tools are just fine. – Jonah Jul 23 '10 at 19:26
I don't understand the distinction you're making between "comparing" and "diffing". The solution that you accepted in the other question used diff as a final step, and should tell you "what folders/files are in one tree and not the other". Can you clarify what you need that it doesn't give you? – coneslayer Jul 23 '10 at 19:26
up vote 7 down vote accepted

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
share|improve this answer

Not the answer you're looking for? Browse other questions tagged .