Are my source and backup directories truly identical?

Quick Linux Tip #17:

Try: diff <(cd /source && find . -type f -exec md5sum {} + | sort) <(cd /backup && find . -type f -exec md5sum {} + | sort)

Info: Combines find, md5sum, sort, and process substitution to compare directories by content, not just names. Detects even single-byte modifications.

Examples:

  • $ rsync -avnc /source/ /destination/  # Dry-run checksum check
  • $ find /a -type f | xargs sha256sum | sort > /tmp/a.sums
  • $ sha256sum -c backup.sums  # Verify files against saved hashes

Note: Use sha256sum for security-critical checks. rsync -c performs checksum-based comparison without transferring files during a dry run. Perfect for backup verification.




LinuxTeck.com
linuxteck@ubuntu:~$ diff <(cd /source && find . -type f -exec md5sum {} + | sort) <(cd /backup && find . -type f -exec md5sum {} + | sort)

18a19
> d41d8cd98f00b204e9800998ecf8427e  ./docs/newfile.txt
45c46
< a3b5c7d9e1f3a5b7c9d1e3f5a7b9c1d3  ./config/app.conf
---
> b4c6d8e0f2a4b6c8d0e2f4a6b8c0d2e4  ./config/app.conf

PREVIOUS ARTICLE Quick Linux Tip #16: Why is my repeated SSH connection so slow, and how do I fix it? NEXT ARTICLE Quick Linux Tip #18: How do I automatically reload nginx when its config changes?
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.