Folder alpha has one subfolder, and files in both root and in subfolder.

Folder beta has 25 subfolders with files in them.

How would I compare the file contents of alpha and beta, checking for difference in files?

  • Have you tried diff?
    – jimmij
    Oct 11 '14 at 20:12
  • I looked into it, but couldn't find how to include all subfolders files. Or does it suffice comparing the two main folders and it automatically include everything inside?
    – Numbers
    Oct 11 '14 at 20:15

Assuming the file and directory names don't have newlines in them:

diff  <(cd alpha ; find . -type f) <(cd beta; find . -type f)

The find commands list the files in the directories the cd changed to and the diff compares the listings. Output looks like:

< ./b/c/file.x
> ./b/c/file.d
> ./b/c/file.e

with < indicating files only in alpha and > only in beta

  • I'm comparing folders with ~ 30 000 files, and the file difference will be in the hundreds. Is there any way to only output the missing files?
    – Numbers
    Oct 11 '14 at 20:18
  • @Numbers, updated the answer.
    – Anthon
    Oct 11 '14 at 20:26
  • "find: illegal option -- t"
    – Numbers
    Oct 11 '14 at 20:28
  • @Numbers There was a . missing after the first find. (The one from GNU findutils doesn't seem to care about it).
    – Anthon
    Oct 11 '14 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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