Find Duplicate Files by Checksum
List files whose contents are byte-for-byte identical, even with different names.
01Command
$ 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
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- shasum – Calculate SHA checksumsEvidence: Checksum tools (md5/shasum) produce identical hashes for identical content — the basis of duplicate detection.
- find – Walk a file hierarchyEvidence: 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
List the biggest files in your home folder that are eating disk space.
Make Finder display .pdf, .docx, .png and every other extension at all times.
List every open file descriptor — files, directories, and network sockets — per process.