Find Duplicate Files by Checksum

List files whose contents are byte-for-byte identical, even with different names.

macOSFilesduplicatesLow risk
Run the find + md5 pipeline to print the path of every file that has an identical twin elsewhere in the tree.

01Command

Command
$ cd ~/Downloads && find . -type f -not -name ".DS_Store" -exec md5 -r {} + | sort | awk '{c[$1]++; f[$1]=$2} END {for (h in c) if (c[h]>1) print f[h]}'

02What it does

md5 -r prints "hash filename"; sorting by hash puts identical files next to each other and the awk step keeps one path per hash seen more than once. This catches true duplicates only — two photos saved at different moments or quality levels have different hashes. Delete confidently only after eyeballing the list, or export it with > duplicates.txt.

03Risk

RiskLow risk
!Warning: A matching hash means identical bytes, but check before deleting — the list includes every copy, so keep one per group.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • shasum – Calculate SHA checksums
    ss64.com · technical · 2026-09-17
    Evidence: Checksum tools (md5/shasum) produce identical hashes for identical content — the basis of duplicate detection.
  • find – Walk a file hierarchy
    ss64.com · technical · 2026-09-17
    Evidence: find -type f -exec runs the checksum tool over every file in the tree in batches.

Last verified: 2026-09-18 · Category: Files & Folders

06Related solutions