# 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.

Source: https://fullbytedeveloper.com/blog/finding-things-find-fd-rg
Published here: 2026-12-03, updated 2026-12-03

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](/blog/essential-linux-commands-developers-part-1), [CLI tools matched to jobs](/blog/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`:

```bash
find . -name 'PUBLISHING.md' -print
rg -n "Quick start" --glob '*.md' src/content/resources | head
```

You 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):

```text
$ 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

<figure aria-label="Question branches to find or fd for paths and ripgrep for file contents">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 220" role="img" aria-hidden="true">
  <defs>
    <marker id="findingthingsfindfdrg-sr-arr" markerWidth="8" markerHeight="8" refX="7" refY="4" orient="auto">
      <path d="M0,0 L8,4 L0,8 Z" fill="#14b8a6"/>
    </marker>
  </defs>
  <rect x="0" y="0" width="360" height="220" rx="12" fill="#0b1f3a"/>
  <text x="180" y="28" text-anchor="middle" font-size="12" font-weight="600" fill="#e6edf7" font-family="system-ui,sans-serif">name or contents?</text>
  <rect x="30" y="45" width="120" height="70" rx="6" fill="#123052" stroke="#14b8a6" stroke-width="1.125"/>
  <text x="90" y="76" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">find / fd [1] [2]</text>
  <text x="90" y="94" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">paths, metadata</text>
  <rect x="210" y="45" width="120" height="70" rx="6" fill="#123052" stroke="#14b8a6" stroke-width="1.125"/>
  <text x="270" y="76" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">ripgrep rg [3]</text>
  <text x="270" y="94" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">regex in file bytes</text>
  <line x1="180" y1="36" x2="90" y2="50" stroke="#14b8a6" stroke-width="1.125" marker-end="url(#findingthingsfindfdrg-sr-arr)"/>
  <line x1="180" y1="36" x2="270" y2="50" stroke="#14b8a6" stroke-width="1.125" marker-end="url(#findingthingsfindfdrg-sr-arr)"/>
  <rect x="90" y="124.5" width="180" height="55" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="0.9" stroke-dasharray="3 3"/>
  <text x="180" y="150" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">default: respect .gitignore</text>
  <text x="180" y="166" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">rg -uuu only on purpose</text>
  <text x="180" y="204" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">narrow with fd, then rg inside that folder</text>
</svg>
</figure>

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:

```bash
find . -name '*.md' -print | head
```

You 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:

```bash
fd 'readme' -e md
```

You 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.

```bash
rg -n "TODO" --glob '*.ts' | head
```

You 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:

```bash
grep -R -n "TODO" --include='*.ts' . | head
```

grep 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:

```bash
rg -n "platform_post_urls" src/content/resources | head
```

That 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:

```bash
find src -maxdepth 3 -type f -name '*.astro' -print | wc -l
```

You 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]:

```bash
rg -c "platform_post_urls" src/content/resources | head
```

Observed on this draft host (2026-12-03):

```text
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:1
```

The `-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](/blog/neovim-quick-start-calm-setup).

Send this to the friend who opens Finder when ripgrep would finish in a second.

Image: Concept illustration splitting file tree search with find or fd from content search with ripgrep and gitignore shield, no people and no readable text.
https://fullbytedeveloper.com/media/finding-things-find-fd-rg/finding-things-find-fd-rg-venice.webp
Name search and content search are two different tools.

## Sources

1. [Linux man-pages: find(1), accessed 2026-12-03](https://man7.org/linux/man-pages/man1/find.1.html)
2. [sharkdp/fd README, accessed 2026-12-03](https://github.com/sharkdp/fd)
3. [BurntSushi/ripgrep README, accessed 2026-12-03](https://github.com/BurntSushi/ripgrep)
4. [Full Byte Developer: Essential Linux commands part 1](https://fullbytedeveloper.com/blog/essential-linux-commands-developers-part-1)
5. [Full Byte Developer: CLI tools matched to jobs](https://fullbytedeveloper.com/blog/cli-tools-matched-to-jobs)
