Interlinked.

Comparisons · measured July 2026 · 6 min

grep vs find: which does what.

find
searches by NAME & attributes

Matches the file’s label: name, size, date, type. Never opens the file.

$ find . -name "*.log"
grep
searches CONTENTS

Matches the text inside files. Opens each one and scans every line.

$ grep -r "TODO" .

Two of the oldest tools on any Unix machine, endlessly mistaken for each other, and the AI coding agent on your laptop still runs both, dozens of times a session. The rule is simpler than it looks: find matches the file's label; grep reads what's inside. Below: the clean picture, the recipes for each, and the one thing they share that an index quietly removes.

TL;DR · the short version

Two tools, one bottleneck, one index that removes it.

  • find matches the label; grep matches the contents. find reads a file's name, size, date, and type and never opens it. grep opens each file and scans every line. Same folder, two different questions.

  • Both share one bottleneck: they walk the disk. Nothing is precomputed, so cost scales with the size of the drive (4.47M files here), not the size of your question. find only beats grep because reading a label is cheaper than opening a file.

  • A live index answers both without the walk. It reads every label and every line once, in the background, then finds by name in 85 µs (412,000× faster than VS Code) and by content in 16 ms, versus ripgrep's 93.8 s (58,625×). It opens nothing.

  • It stays fresh and stays small. Save a file and it's searchable again in about 1 ms; the whole engine idles around 44 MB. Keep find and grep: the index just answers first, machine-wide.

The confusion, cleared up

A file is a box. find reads the label. grep opens it.

Every file offers a search two surfaces to match on: the label stuck to the outside (its name, size, date, type) and the contents sealed inside. find only ever reads labels; that's why it can filter by size or age but has no idea what a file says. grep opens the box and reads every line; that's why it finds a phrase anywhere but can't filter by date. One distinction, and everything else about how they behave falls out of it.

THE CLASSIC MIX-UP, SETTLED: A FILE IS A BOXTHE LABELreport_final.pdf4.2 MB · modified Tue · type pdfTHE CONTENTSmatchfindreads the LABELname · size · date · type.Never opens the file.find . -name "*.pdf"find . -size +100Mfind . -mtime -7grepreads the CONTENTSthe text inside the file.Opens it, scans every line.grep -r "TODO" .find matches the label. grep matches the contents. Same folder, two different questions.BOTH WALK THE DISK TO ANSWER. AN INDEX ALREADY READ ITone lookup · either question · 4.47M files · opens nothingASK BY NAME*.pdfASK BY CONTENTparseConfigLIVE INDEXread every label + every line, onceopens no files · walks no treefresh ~1 ms after every save85 µsfound by name412,000× vs VS Code · 35 s16 msfound by content58,625× vs ripgrep · 93.8 ssame machine · Ryzen 9 9950X3D · 64 GB DDR5 · NVMe · Windows 11 · 4.47M files

Top: the one distinction that settles the mix-up. find matches the label, grep matches the contents. Bottom: the same two questions handed to one pre-built index, answered by name in 85 µs and by content in 16 ms, opening no files. Ryzen 9 9950X3D · 64 GB DDR5 · NVMe · Windows 11 · 4.47M files.

The field guide

Reach for find when you know something about the file. Reach for grep when you know something in it.

The tell is in your question. Anything about the file as an object (its name, how big it is, when it changed, whether it's a folder) is a job for find. Anything about what the file says is a job for grep.

find
BY NAME & ATTRIBUTES
by name pattern
find . -name "*.log"
name, case-insensitive
find . -iname "readme*"
by size, over 100 MB
find . -size +100M
by time, last 7 days
find . -mtime -7
directories only
find . -type d
then act on the matches
find . -name "*.tmp" -delete
grep
BY CONTENTS
text inside files
grep -r "parseConfig"
case-insensitive
grep -ri "error"
show line numbers
grep -rn "TODO"
just the filenames
grep -rl "apiKey"
grep is a tight loop of C on one file or a pipe, genuinely hard to beat. Its modern cousin ripgrep keeps the same idea and searches every core at once.
AND THE CLASSIC PAIRING EVERY DEV EVENTUALLY MEMORIZES
$ find . -name "*.py" | xargs grep "import"

find picks the files by name; grep searches inside those. Two tools, two passes: one walk to narrow by label, a second to read the contents. Hold onto that shape: it's exactly the work an index collapses into a single lookup.

What they have in common

Different questions. Identical bottleneck.

For all their differences, find and grep are built the same way underneath: to answer, they walk. find walks the directory tree reading labels; grep walks it and opens every file to read the contents. Nothing is precomputed: the work starts the instant you press Enter, and the cost is set by the size of the disk, not the size of your question.

On a laptop with one project open, you never feel it. On a real machine (4.47 million files across a dozen repos, plus everything that was never in git) the walk is the whole cost. Double the files and you double the wait, on every query, forever. find is faster than grep because reading a label is cheaper than opening a file, but both scale with the drive. That shared ceiling is the thing an index removes.

The same two questions, measured

Ask once. Answer either way. Without the walk.

A purpose-built index does the walk exactly once, in the background, then keeps itself fresh as files change. At query time there's no tree to crawl and no file to open: it reads the index and returns the matches. Here is the same 4.47-million-file machine answering both of find's and grep's jobs, against the tools that walk for each.

The questionA tool that walks for itIts timeInterlinkedSpeedup
Find a file by name
find’s job
VS Code Ctrl+P35 s85 µs412,000×
Search the machine by name
find’s job
Windows Search (median)67 s139 µs~480,000×
Find files by content
grep’s job
ripgrep (rg)93.8 s16 ms58,625×

Same machine, same 4.47M-file NTFS volume: Ryzen 9 9950X3D · 64 GB DDR5 · NVMe · Windows 11. Filename lookups are 85 µs for a single file (best case 2 µs) and a 139 µs median across 20 queries; content search runs ~7 to 9 ms typical (rare symbols ~7 ms, common words ~9 ms), with exact phrases around 16 ms, the query timed above. VS Code Ctrl+P and Windows Search are name-search proxies for find's job; ripgrep runs with default settings. Raw find and grep do the same directory walk with fewer tricks, so they land slower still: we timed the fastest walkers on purpose.

One index, both questions

find's answer and grep's answer, from the same lookup.

The point isn't that the index is a faster find or a faster grep. It's that it's both at once, machine-wide. Ask what a file is called or ask what's written inside it, and the same live index answers in the microsecond-to-millisecond range, opening nothing. And it never goes stale: save a file and it's searchable again in about a millisecond.

85 µs
to find a file by name across 4.47M, 412,000× faster than VS Code’s 35-second search. 139 µs median across 20 queries.
16 ms
one content query on the same machine: ripgrep took 93.8 s for it. ~7 to 9 ms typical across the query set, 58,625× faster.
~1 ms
from saving a file to it being searchable again, under 30 ms in the worst case. No re-scan, no stale index.

An index sounds heavy until you measure it. The whole engine sits around 44 MB at rest (less than a single browser tab) and the index takes under 1% of the drive (about 24 GB on a 4 TB machine). Keep find for the label. Keep grep for one file. Give the machine one floor that answers both, instantly.

Common questions

grep, find, and the index that answers both.

What is the difference between grep and find?

find searches by a file's label (its name, size, date, and type) and never opens the file. grep searches the contents, opening each file and scanning every line. One question is about the file as an object; the other is about what it says.

When should I use find, and when grep?

Use find when your question is about the file itself: a name pattern, a size, an age, whether it's a folder. Use grep when it's about the text inside. The classic pairing find … | xargs grep … uses find to narrow by name, then grep to read only those files.

Is find or grep faster?

find is faster because reading a label is cheaper than opening a file, but both scale with the size of the disk, not the size of your question. Every query walks the tree from scratch, and on a 4.47M-file machine that walk is the whole cost.

How can a search be instant across millions of files?

A prebuilt index does the walk once in the background, then answers from memory. It finds a file by name in 85 µs (412,000× faster than VS Code and ~480,000× faster than Windows Search's 67 s) and searches contents in 16 ms, versus ripgrep's 93.8 s (58,625×). It stays fresh about 1 ms after each save and idles near 44 MB.

Why does this matter for an AI coding agent?

An agent re-runs find and grep dozens of times a session. One real task took an agent 6 min 57 s across 71 tool calls walking the disk; from the index the same answer is 16 ms and a single call, roughly 7,200,000× less waiting, with the token cost of all that searching dropping from ~58% toward ~0%. Everything local is free, forever: the app, whole-machine search, MCP. Hosting starts at $5.99/mo.

Keep both. Add the index.

Give your agent one lookup for both.

1

Install once. One signed installer wires up 19 AI clients: Claude Code, Cursor, Copilot, Codex, Windsurf, Zed and the rest. No JSON to edit.

2

Keep find and grep. They stay exactly where they are, perfect for one file or a scripted pass. The index just answers first, machine-wide, by name or by content, in the microsecond-to-millisecond range.

3

Let it stay fresh. Save a file and it’s searchable again in about a millisecond. At rest the whole engine sits around 44 MB and the index takes under 1% of the drive.

4

Ask both ways. “What’s it called” and “what’s inside” resolve from the same index, so your agent stops walking the disk on every question it can’t answer from memory.

Everything local is free forever, on all your devices, no card. Hosting starts at $5.99/mo. Download for Windows.

Measured July 2026 · Ryzen 9 9950X3D · 4.47M files · Windows 11← All research