# An empty ripgrep result does not mean the client's logs are clean

> Three tools beat grep and find on speed, but their default filters can hide the very file a forward deployed engineer needs on day one.

Original: https://fdetimes.net/en/tools/ripgrep-fd-fzf-empty-results/

ripgrep, the search tool written by Andrew Gallant, ignores everything listed in `.gitignore` by default, along with hidden files and binary files. That is a large part of why it runs so fast on a codebase. It is also why it can go quiet at the very moment you most need an answer.

For a forward deployed engineer, that moment usually arrives on the first day at a client site. You inherit a codebase you have never read, a log directory weighing several gigabytes, and very little time to show where the fault lies. Three tools, ripgrep (`rg`), fd and fzf, will carry you far faster than `grep` and `find`, provided you know exactly what they are filtering out.

## One tool, one job

`rg` searches an entire directory tree for a regex pattern and runs on Rust's regex engine. The official repository states that it has first-class support for Windows, macOS and Linux. That matters when you do not get to choose the machine: today it is your own Mac laptop, tomorrow a client's Linux server or Windows workstation.

fd, a repository by sharkdp, describes itself as a simple, fast and user-friendly alternative to `find`. It walks directories in parallel, can run commands in parallel on each result, and, like `rg`, skips patterns in `.gitignore`. fd is dual-licensed under MIT and Apache 2.0.

fzf, by Junegunn Choi, is a general-purpose fuzzy finder distributed as a single binary under the MIT license. Its author says it is optimized to process millions of lines in milliseconds, and it ships with integrations for Bash, Zsh, Fish, Nushell, Vim and Neovim.

If the client runs a security review before you may install tools, have the license details for all three ready.

## Where the speed comes from

In 2016 Gallant published a benchmark comparing ripgrep with grep, ag, git grep, ucg, pt and sift. His conclusion: no other tool clearly beat ripgrep on either performance or correctness, and ripgrep achieved that with Unicode support switched on.

Those are the author's own measurements from 2016, so treat them as a starting point and rerun the numbers on the client's data.

The benchmark contains one point worth keeping in mind for anyone who reads logs: memory maps are not always faster. Gallant wrote that tools searching many files at once tend to be slower when they use memory maps, so ripgrep picks its reading strategy according to the workload.

One enormous log file and thousands of rotated log files are different problems. When you measure, try both.

## When rg finds nothing

Take a hypothetical case. The client's repo has a `logs/` line in `.gitignore`, because nobody wants to commit logs. You stand at the repo root and search for a connection error:

```bash
rg 'connection reset' .
# no results at all
```

Read in a hurry, this suggests the error is not in the logs, and you start suspecting the network. In fact `rg` never opened the `logs/` directory. The triple flag `-uuu` switches off every default filter: `.gitignore`, hidden files and binary files.

```bash
rg -uuu 'connection reset' .
# this time rg also searches logs/, hidden files and binary files
```

**Key point:** An empty search result is only trustworthy when you know what the tool skipped.

Make this a reflex: when a search comes back empty, rerun it with `-uuu` before telling the client anything. fd also skips `.gitignore` patterns by default, so when its listing is missing a file you are sure must exist, open `.gitignore` before concluding the file is not there.

## Joining the three with pipes

Because each tool does one job, they are most useful when the output of one becomes the input of the next. fd finds files by name, say every file with `config` in its name in an unfamiliar repo. Pipe that into fzf and you get a list that narrows with every character you type:

```bash
fd config | fzf
rg -uuu 'ERROR' . | fzf
```

The second command is the pattern you will reach for most, and it keeps `-uuu` for the reason above: logs often live in gitignored directories. `rg` gathers every error line, and fzf lets you filter further by service name, error code or timestamp without retyping the regex.

On fzf's official site, Junegunn Choi maintains a "Ripgrep integration" page explaining how to use fzf as an interactive front end for `rg`. Read it before writing scripts of your own.

## What to learn first

Start with `rg`, because it is the tool you will use every hour on a client site. Get comfortable writing regexes, and remember the three default filters and `-uuu`. Next comes fzf, with its integration for your shell and editor. Leave fd for last; `rg` and fzf are often enough.

For your career, this skill belongs on a CV as a concrete story rather than a line listing tool names. State how many gigabytes of logs you searched to find the root cause, how long it took and which command did it.

In interviews with a live debugging round, typing `rg` and then checking yourself with `-uuu` shows the interviewer that you know to doubt your own tools.

Clients do not pay for how fast you type. They need a correct answer about their system, and with `rg` the correct answer is sometimes just three letters `u` away.

**Try this week:**

- Pick a repo with a directory listed in .gitignore, search for the same string with rg and with rg -uuu, and compare the two results.
- Install fzf with the integration for the shell you use, and read the Ripgrep integration page on fzf's official site.
- Rewrite your most recent log-debugging session as a single CV line that includes the command, the volume of data and the time it took to find the cause.

## Sources

- [GitHub - BurntSushi/ripgrep](https://github.com/BurntSushi/ripgrep)

- [ripgrep is faster than {grep, ag, git grep, ucg, pt, sift}](https://burntsushi.net/ripgrep/)

- [GitHub - sharkdp/fd](https://github.com/sharkdp/fd)

- [GitHub - junegunn/fzf](https://github.com/junegunn/fzf)

- [fzf - a command-line fuzzy finder](https://junegunn.github.io/fzf/)
