Search the Spotlight index from the terminal
Build a paste-ready command, then review its compatibility and effects before running it.
Complete required fields to copy the generated command.
read-onlyno known side effects Compatibility
macOSVerified for macOS using zsh, bash syntax.
Operational knowledgereview due 2027-01-19
Requirementsmdfindmdfind must be installed and available on PATH.
Version supportmdfind Current supported releasesVerified for macos using zsh, bash syntax; consult compatibility notes for platform-specific differences.
Expected signals/Users/alex/Documents/Invoices/invoice-2026-07.pdfRepresentative successful output; values vary with the selected target and system state.
Known errorsmdfind: command not foundmdfind is missing or is not available on PATH.
Verifymdfind {{query}}The output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01mdfindSpotlight searchQueries the macOS Spotlight metadata index.
02"invoice"Search queryReplace this quoted text with the filename, content, or metadata term to find.
Example input
mdfind "invoice"
Example output
/Users/alex/Documents/Invoices/invoice-2026-07.pdf
/Users/alex/Downloads/invoice-template.pages
Illustrative output — exact values vary by system and data.
Runbooks
Official sources