grep for people who don't use Terminal: searching inside files on a Mac
Your Mac has two ways to look inside files. Spotlight is the search you already use (⌘-Space, or the search box in Finder). grep is a 50-year-old command that programmers type in Terminal. They're good at different things, and knowing which one misses what saves a lot of "I know that file is here somewhere".
We ran the same searches with both on one folder of our own notes and code: 11,440 files, 793 MB, mostly plain text and Markdown, on a Mac mini running macOS 27.0.1 (23 October 2026). Spotlight was run as mdfind -onlyin, which is the same index the search box uses.
The results
| Search | Spotlight | grep |
|---|---|---|
| The word "waitlist" | 49 files in 0.17 s | 50 files in 0.22 s (0.02 s the second time) |
| "waitlist", any capitals | 49 (always ignores case) | 52 with -i (3 more files, where it is written only with capitals) |
| The start of a word: "waitl" | 50 (matches word beginnings) | 50 |
| "list" as its own word | 1,879 files (anything with a word starting "list", in the text or the file's details) | 759 contain "list" anywhere; 551 as a whole word with -w |
| A pattern: "CR-03" plus two digits | can't do it | 77 files with -E "CR-03[0-9]{2}" |
| A word inside a 131-page PDF | found | not found (PDF text is compressed) |
| A word inside a Word (.docx) file | found | not found (.docx is a zip file) |
What that means in plain words
Spotlight is better for documents
Spotlight reads PDFs, Word, Pages, Keynote, email and more, because each app ships a small reader that turns the file into text for the index. grep only reads plain text. In our test, grep found nothing inside a 131-page licence agreement PDF that Spotlight found in a fraction of a second, and it missed a sentence in a Word file that we had just saved.
grep is better at being exact
Spotlight is tuned to be forgiving: it ignores capitals and accents and matches the beginnings of words. That's why "list" brought back 1,879 files: everything with "list", "listing", "lists" and the like, in the text or in details such as the file name. You can't tell it "only the whole word", "match capitals exactly", or "CR-03 followed by two digits".
grep does exactly what you ask: -w for whole words (551 files instead of 759), -i to ignore capitals when you want that, -E for patterns like "two digits" or "this or that", and -n to show the line number of each hit.
Both are fast
On 11,440 files both answered in under a quarter of a second. Spotlight is fast because its index is built ahead of time. grep reads every file each time, but macOS keeps recently read files in memory, so the second grep took 0.02 s. On a slow external disk or a folder with large files, grep would be the slower of the two.
Spotlight tricks most people don't know
You can get closer to grep without Terminal. In the Finder search box or Spotlight, these work:
| Type this | To get |
|---|---|
"quarterly budget" (with quotes) | the exact phrase, not the two words anywhere |
budget kind:pdf | only PDFs (also kind:image, kind:folder, kind:email) |
budget date:10/1/26-10/23/26 | files from those dates (the date format follows your region settings) |
budget OR travel, budget NOT draft, budget -draft | either word; one but not the other (the minus sign is a shortcut for AND NOT) |
author:tom | documents by an author |
In a Finder window you can also press ⌘-F, then use the "+" button to add rows such as "Contents contains", "Kind is PDF" and "Last modified date is within last 7 days". Save the search and it appears in the sidebar as a Smart Folder.
If you do want to try grep
Open Terminal (Applications → Utilities) and paste one of these. Replace the folder and the words with yours. They only read; they never change a file.
# files in Documents that contain "invoice", any capitals
grep -rli "invoice" ~/Documents
# the whole word "tax", with the line and line number of each hit
grep -rnw "tax" ~/Documents
# only in Markdown and text files
grep -rli --include='*.md' --include='*.txt' "invoice" ~/Documents
# a pattern: invoice numbers like INV-2026-0042
grep -rlE "INV-2026-[0-9]{4}" ~/Documents
# Spotlight's index from Terminal, which also searches PDFs and Word files
mdfind -onlyin ~/Documents "invoice"Where Zofle fits. Zofle's search, in our free Mac app coming soon to the Mac App Store, puts both in one box: it looks inside documents the way Spotlight does, and offers grep's exact options as plain switches (exact words, match capitals, file type, date and size). One search across your Mac and iCloud. Find your files quick, quick.
Sources and method
- Our tests, 23 October 2026: Mac mini (M4), macOS 27.0.1, Spotlight indexing on. Folder of 11,440 files (793 MB, the
.gitfolder excluded from grep). Commands:mdfind -onlyin,grep -rIlwith-i,-w,-E, timed with the shell'stime. The PDF was a 131-page agreement downloaded from Apple; the Word file was a one-line note saved as .docx withtextutil, then deleted. - Apple: Narrow your search results in Finder on Mac (keywords and AND, OR, NOT).
man grepandman mdfindon macOS.
Zofle Pro news
People signing up now will get Zofle Pro, with more features, for free when we launch it.