Ramblings of an aging IT geek
← Ramblings of an aging IT geek
tooling

i finally stopped reaching for grep and find

After years of muscle memory, ripgrep and fd replaced grep and find in my daily work, mostly because they are faster and respect .gitignore.

A mechanical keyboard lit beside a terminal

I have typed grep -rn and find . -name so many times over so many years that my fingers reach for them before my brain engages. That muscle memory is exactly why it took me embarrassingly long to switch. The old tools were not broken. They were just slower and noisier than what had quietly replaced them, and I had stopped noticing because I had never known anything else.

The thing that finally moved me was searching a large monorepo and waiting. Plain grep -r happily trawls node_modules, the .git directory, build output, vendored dependencies, the lot. You end up wrapping it in a pile of --exclude-dir flags you can never quite remember, or piping through more grep -v to filter the noise back out.

The kind of search result wall the old tools used to bury me in

ripgrep

ripgrep, rg, does the obvious thing that took someone surprisingly long to build: it reads your .gitignore and skips everything you have already declared you do not care about. So a search over the same repo returns just the source files, and it does it faster because it has less to read and is multithreaded underneath.

rg 'context.Background' --type go

That searches only Go files, skips anything ignored, and finishes before the old version has finished thinking about node_modules. The type filters alone replaced a small library of aliases I had accumulated. The output is sensible by default too: grouped by file, line numbers on, colour where colour helps.

fd

fd is the same idea applied to find. The find syntax has never once stayed in my head. I always end up at the man page to remember where the predicate goes and why my expression matched nothing. fd flips it round so the common case is the easy one.

fd '\.go$' internal/

That is "find Go files under internal", ignoring the usual junk, with a regex by default and no -name ceremony. When I want the old all-files behaviour I add a flag, but I almost never want it.

was it worth changing

I resisted this for a long time on the reasonable grounds that grep and find are everywhere and these are not. On a strange server at three in the morning I will still happily fall back to the classics, and I am glad the muscle memory is there. But on my own machines, where I do the bulk of my actual thinking, the new tools have paid for the retraining many times over. Faster, quieter, and they default to caring about the same files I do.

The old tools earned their decades. I am just no longer willing to wait for them when I do not have to.