I have 2 folders, and I want to know if folder#1
has all the files in folder#2
How can I check this?
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
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.