How do I find duplicate files taking up space on my Mac?

Locate and remove byte-for-byte duplicate files from the macOS Terminal: rank folders by size, list duplicates by checksum, delete them in one batch, and verify the reclaimed space.

macOScleanupFilesduplicatesstoragediskdisk-spaceHigh risk
Rank your home folder with du to find the heaviest directories, then list duplicates by checksum inside the worst one.

What this covers

Duplicate downloads, copied photos, and synced folders quietly pile up until your Mac's disk fills. This guide walks you from finding where the space went, through identifying true duplicates by checksum, to deleting them safely from the Terminal.

Symptom

?Storage warnings keep appearing, the disk keeps filling even though you haven't added anything obvious, and scrolling through Finder you suspect you have the same files saved in several places.

Find out which folders are eating the most space

Before hunting for duplicates, see where the space actually goes. Ranking your home folder's top-level directories by size shows you which area (Downloads, Documents, Photos…) is worth investigating. When the command finishes, the biggest folders are listed at the top — start your duplicate search there.

du measures folder sizes; sorted through sort -rh and cut with head, it shows the top space consumers.

Command
$ du -xsh ~/* 2>/dev/null | sort -rh | head -15

Drill into a suspicious folder

Once you've picked the folder most likely full of duplicates (Downloads is a usual suspect), rank its subfolders by size. This narrows the search so the checksum pass runs faster and you focus on directories that actually hold weight. You should see a sorted list with the heaviest subfolders last.

macOSShow Folder Sizes Sorted with du -shLow riskStep 2Optional

Rank every folder by disk usage, biggest last, in human-readable units.

Command
$ du -sh */ | sort -h

List the actual duplicates by checksum

Files can have different names but identical contents. A checksum comparison finds every byte-for-byte copy, so you know exactly which files are safe to remove. First cd into the folder you identified, then run the checksum listing. The output is one path per duplicated file group — those are your reclaimable copies.

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

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]}'

Delete the duplicate copies in one batch

With the duplicate list in hand, use find -exec to remove the copies in one pass instead of deleting them one by one. Be precise: match only the exact filenames you confirmed as duplicates — a broad pattern will delete files you wanted to keep. When done, the paths from the checksum list should no longer exist.

find -exec turns every search result into an argument of another command, replacing fragile shell loops and xargs plumbing for tasks like deleting all .DS_Store files in a tree.

Command
$ find . -name "*.tmp" -exec rm {} +
find . -name "*.DS_Store" -type f -exec rm -v {} \;

Confirm the space is reclaimed

Re-run a size check over your home folder to confirm the cleanup worked. You should no longer see the duplicate copies in the results, and the folder you cleaned should have shrunk compared to your earlier du ranking.

macOSFind files larger than 500 MB on MacLow riskStep 5Optional

List the biggest files in your home folder that are eating disk space.

Command
$ find ~ -type f -size +500M 2>/dev/null -exec ls -lh {} \;
!Deletion is permanent — files removed from the Terminal do not go to the Trash. Only batch-delete files you have confirmed as duplicates by checksum, and double-check the filename pattern before running a delete command.

How to confirm it worked

Re-run a large-file listing over your home folder: the duplicate copies should be gone and the cleaned folder should be measurably smaller than in your initial du ranking.

Sources

  • du — disk usage (macOS man page)
    SS64 · technical · 2026-09-17
    Evidence: Documents du -s (summary per argument), -h (human sizes) and -x (stay on one filesystem).
  • 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-21

Related guides