Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I have 2 folders, and I want to know if folder#1 has all the files in folder#2

How can I check this?

share|improve this question
A little more information please. What OS? Do you want scripting based solutions, or purely third party programs? – Matrix Mole May 26 '11 at 22:39
up vote 7 down vote accepted

Giving that folder2 for example has an extra file named test4, but they share all other files in common, you can always use diff.

diff folder1 folder2

In our case that would return:

Only in folder2: test4
share|improve this answer

Assuming you want to find missing files/directories on folder2 from folder1, you do:

ls folder2 > /tmp/f2.txt
ls folder1 | grep -v -f /tmp/f2.txt

That will list all items present in folder1 but not in folder2, you can do the opposite to find both differences.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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