See if folder x has all the files in folder z

4

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

How can I check this?

user27449

Posted 2011-05-26T22:26:57.880

Reputation: 5 104

A little more information please. What OS? Do you want scripting based solutions, or purely third party programs? – Matrix Mole – 2011-05-26T22:39:07.647

Answers

7

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

slhck

Posted 2011-05-26T22:26:57.880

Reputation: 182 472

1

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.

ghm1014

Posted 2011-05-26T22:26:57.880

Reputation: 231