Skip to content

Search with Spotlight from Terminal (mdfind) — via SS64

Commandlow riskmacOS 14 Sonoma and later

mdfind runs Spotlight searches from the command line, so it's instant even across your whole drive. It can search by name, by content, or by metadata like 'images edited yesterday' or 'files tagged Green'.

Takes effect right away

The easy way

  1. mdfind -name report.pdf finds files by name; mdfind budget searches contents and metadata too.
  2. -onlyin ~/Documents limits the search to one folder; -count just counts matches.
  3. Metadata searches: mdfind "kind:image date:yesterday", mdfind "kMDItemUserTags = Green", or mdfind kMDItemAppStoreHasReceipt=1 to list App Store apps.

Command

Run in Terminal (Applications › Utilities).

mdfind -name invoice -onlyin ~/Documents
It only finds what Spotlight has indexed, so folders excluded in Spotlight settings won't show up.

Sources

Source reviewed
2026-11-02
Link checked
2026-11-02
Tested hands-on
Not by Oddbyte.Me

Oddbyte.Me hasn't tried this on every macOS version, so keep the undo handy.

mdfindspotlightsearchterminalfind filesmetadata

More in Hidden Tools & Commands

Download a full macOS installer from Terminal — via SS64

Commandlow risk

softwareupdate can list and download complete macOS installers, including older versions Apple still serves. Useful for making a bootable USB installer or installing on another Mac without hunting through the App Store. This entry only downloads; it doesn't install anything.