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 have quietly replaced grep -r and find in my daily work, and I'm not going back.

A keyboard lit by a terminal window

I've typed grep -rn pattern . more times than any other command in my life, and this is the year I admit I've stopped. ripgrep and fd won, and the thing that finally did it wasn't a benchmark. It was that they're correct by default in the ways I always had to remember to be.

rg pattern searches recursively, skips your .git directory, respects your .gitignore, and doesn't waste time grinding through node_modules looking for matches you'd never want. With plain grep I had to assemble all of that by hand every time: the -r, the --exclude-dir, the --include for file types. Half the time I'd forget one and either drown in vendored-code noise or miss the file I wanted. ripgrep just does the sensible thing, and on a large repo it's noticeably faster too, because it isn't reading rubbish it should be ignoring.

fd is the same trade for find. Compare finding every Rust file under here:

find . -name '*.rs' -not -path './target/*'
fd -e rs

The second one is what I mean. No -name quoting, no remembering that find's predicate syntax predates sensible defaults, and target/ is skipped because it's in .gitignore. It reads like the question I'm actually asking.

I'm not sentimental about this. grep and find are POSIX, they're on every box, and I still use them happily over SSH on a server where installing tools isn't worth it. The portable old tools earn their keep precisely by being everywhere. But on my own machine, where I control what's installed, fighting forty-year-old default behaviour out of loyalty is just nostalgia with extra keystrokes. The muscle memory took a fortnight to repoint. I should have done it years ago.