Finding things: find, fd, and ripgrep
Use find or fd for file names; use ripgrep for file contents. Respect gitignore when the tool offers it.
Published here , updated · 5 sources · Resume reading
Three search tools cover most "where is that?" moments on a Linux box: find for the tree, fd for a friendlier name search, and ripgrep (rg) for contents [1] [2] [3]. Related on-ramps: essential Linux commands part 1, CLI tools matched to jobs.
Quick start (under a minute)
From a git checkout, locate a file by name with find, then search file contents with rg:
find . -name 'PUBLISHING.md' -print
rg -n "Quick start" --glob '*.md' src/content/resources | headYou should see one path for the publishing guide, then several file:line:text hits where other articles use that heading.
Worked example on this draft host
Observed on this draft host (find from GNU findutils, ripgrep 15.1.0, Linux, 2026-12-03):
$ find . -name 'PUBLISHING.md' -print
./PUBLISHING.md
$ rg -n "Quick start" --glob '*.md' src/content/resources | head
src/content/resources/ctrl-c-is-sigint.md:41:## Quick start (under a minute)
src/content/resources/boring-production-box-checklist.md:43:## Quick start (under a minute)
src/content/resources/when-you-need-kubernetes.md:45:## Quick start (under a minute)
src/content/resources/wireguard-vs-tailscale-vs-openvpn.md:45:## Quick start (under a minute)
src/content/resources/finding-things-find-fd-rg.md:43:## Quick start (under a minute)The find line proves the file exists at a known path. The ripgrep lines prove which Markdown files reuse the same section title. Absolute paths depend on where you run the commands. The pattern stays the same in any repo.
Draw the two search lanes
That split is why senior engineers reach for fd readme before rg readme when they only care about filenames [2] [3]. rg -uuu searches as if ignore rules were off; use it when you intentionally need ignored paths, not as a daily default [3]. The memorable habit: say aloud whether you need a path or a line before you type a command.
Find files by name with find
find starts at a path and evaluates expressions such as -name, -type, and -mtime [1]. GNU find's grammar is powerful and verbose. A minimal name search:
find . -name '*.md' -print | headYou should see Markdown paths under the current directory. For production scripts, read man find for predicates, pruning, and -exec safety: a careless -delete combined with a broad path is a career event [1].
Common teaching flags:
| Flag / expression | Role [1] |
|---|---|
. starting path | Root of the walk |
-name 'pattern' | Shell glob on the basename |
-type f | Regular files only |
-maxdepth 2 | Stop recursion early |
find does not read file contents for matching unless you add actions that do. It is the right tool when the question is about paths, sizes, or mtimes.
Find files by name with fd
fd is an alternative front end to the same job [2]. The README summarizes defaults: smart case, ignore hidden files, respect .gitignore, colored output. Typical invocation:
fd 'readme' -e mdYou should see hits such as README.md without descending into ignored vendor trees when those paths are listed in ignore rules [2]. Install fd when you live in large monorepos and want fewer flags than GNU find for daily use.
When fd is missing, stay on find. When both exist, pick fd for interactive speed and find for scripts you must run on minimal containers.
Search inside files with ripgrep
ripgrep recursively applies a regex to each line, respects gitignore by default, skips hidden files, and tries to skip binaries [3]. The README is explicit about ignore semantics and the -u / -uu / -uuu escalation for unrestricted search.
rg -n "TODO" --glob '*.ts' | headYou should see path:line:matching text. Line numbers (-n) matter when you jump straight to an editor. --glob limits extensions so you do not scan assets you never edit.
Useful flags from the README [3]:
| Flag | Effect |
|---|---|
-i | Case insensitive |
-w | Match whole words |
-l | Print paths only, not lines |
-C 2 | Context lines around matches |
-uuu | Disable ignore rules (use on purpose) |
Portable fallback when rg is absent:
grep -R -n "TODO" --include='*.ts' . | headgrep works everywhere; ripgrep is faster on big trees because of parallel IO and ignore handling [3].
Pick the tool from the question
| Question | Tool | Why |
|---|---|---|
| Which path has this name? | find or fd [1] [2] | Directory walk without reading every byte |
| Which file contains this text? | rg [3] | Line-oriented regex at scale |
| Did I mean ignored junk? | Add fd / rg unrestricted flags only on purpose [2] [3] | Defaults hide node_modules for speed |
Keep the first filter cheap
Name searches are cheaper than content scans. If you remember the folder, run fd or find there, then rg with a path argument:
rg -n "platform_post_urls" src/content/resources | headThat habit keeps laptops and CI agents cooler than rg at the repository root for a symbol you already know lives under src/ [3]. The same rule applies inside CI: fail fast on path filters before regex over artifacts.
Script find when you need predicates
Production automation still leans on GNU find because it ships on minimal images [1]. A teaching pattern that limits depth and prints only files:
find src -maxdepth 3 -type f -name '*.astro' -print | wc -lYou should see an integer count of matching paths. Add -mtime -7 when the question is "what changed this week" [1]. Add -empty when hunting zero-byte files after a bad export. The manual lists dozens of primaries; you do not need them all on day one.
When you delete with find, use -delete only after you have printed the same expression without it. A doubled -name typo plus -delete is how backups get interesting.
Count matches without opening every file
ripgrep can report totals before you scroll thousands of lines [3]:
rg -c "platform_post_urls" src/content/resources | headObserved on this draft host (2026-12-03):
src/content/resources/jetbrains-air-agent-review.md:1
src/content/resources/claude-code-remotion-video-setup.md:1
src/content/resources/higgsfield-wan-video-generation-controls.md:1The -c flag prints per-file counts. That is useful when you refactor a field name and want to know blast radius before you edit.
Pair with git and editors
ripgrep's ignore rules mirror what git status already hides. When debugging "why did CI not see this file," check ignore files before you blame the search tool [3]. Most editors embed ripgrep or a compatible engine for project-wide search; the flags in this page translate directly to those panels.
find still wins when git is not involved: system directories, tar extracts, and NFS mounts without a .gitignore. fd can be told to search without ignore when you pass the right flags per its README [2].
Do not do these
Using grep -R on a million-file tree when you only needed find . -name foo. You paid the IO cost of reading every file.
find -name Foo is case insensitive. GNU find's -name is case sensitive unless you use -iname [1].
Thinking rg searched node_modules because "it should be everywhere." Default ripgrep skipped it on purpose [3].
Piping find to grep without -print0 and xargs -0 when filenames contain spaces. Use ripgrep for content, or use safe null-delimited patterns [1].
fd and find are byte-identical. They differ in defaults, speed, and expression language [1] [2].
Running rg from the wrong working directory and concluding the code is gone. ripgrep searches relative to cwd unless you pass a path.
Time yourself once: find a filename with fd, then grep the same token across the repo root. The stopwatch usually teaches the split faster than another cheatsheet. Add alias fdr='fd | rg' only after you can explain which side failed when the result is empty. For a calm editor that keeps those searches close to the buffer, see Neovim quick start.
Send this to the friend who opens Finder when ripgrep would finish in a second.

Keep this guide
Filed under Dev tools, Dev explainers
Questions about this guide
When do I use find versus ripgrep?
find (or fd) walks the tree and matches paths or metadata. ripgrep searches inside file bytes with a regex. Name first, contents second.
What does fd change compared with find?
fd's README positions it as a simpler, faster alternative: smart-case patterns, skip hidden and gitignored paths by default, colorized file types. You trade GNU find's expression grammar for fewer flags day to day.
Does ripgrep search ignored files?
By default it respects gitignore, skips hidden paths, and skips binary files. Use rg -uuu only when you intend to dig through ignored junk.
Is ripgrep installed everywhere?
No. Install from release binaries or your package manager. grep -R remains the portable fallback.
Why does my search miss files in node_modules?
fd and rg both treat common ignore rules as a feature, not a bug. Override deliberately with -uuu or find's -path pruning when you really need those trees.
Sources
- sharkdp/fd README, accessed 2026-12-03github.com
- Full Byte Developer: Essential Linux commands part 1fullbytedeveloper.com
- Full Byte Developer: CLI tools matched to jobsfullbytedeveloper.com