Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
    
Possible duplicate of superuser.com/questions/166317/… –  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
2  
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
show 1 more comment

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.

1 Answer

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
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.