Luke Oliff.

TIL: Finding Files Fast With fd

·TIL·2 min read·Luke Oliff

I still type find out of habit, but fd is the tool I actually want. Where find . -name '*config*' is noisy and ignores nothing, fd is fast, colourised, and respects your .gitignore by default. If you have ever wrestled with find -exec (I wrote about that trick too), fd makes the common cases almost boring.

The technique: find files by name

fd config

That single command searches the current directory recursively, skips ignored files, and highlights matches. No path argument, no -name, no quoting gymnastics. fd treats the pattern as a regular expression, so fd '^config\.' anchors the match to the start of a filename.

The trick: filter by type and run a command per match

The real leverage is fd’s filters plus its exec mode. Restrict by extension and file type, then run a command against every match with -x:

# Count lines across every TypeScript file
fd -e ts -x wc -l

# Run prettier over every file fd finds
fd -e ts -x prettier --write

-e ts limits results to .ts files, -t f would keep files only (drop -t d for directories), and -x runs the command once per result, appending the path automatically. It is the same idea as find -exec but without the semicolons and {} boilerplate. You can also just pipe: fd -e md | wc -l counts your markdown files in a blink.

FAQ

How is fd different from find?

fd defaults to recursive search from the current directory, respects .gitignore, and colourises output, while find ignores nothing and prints plain text. fd also takes a regex pattern instead of a glob, so simple name searches need less typing.

Can I run other commands against the results?

Yes. Use -x to execute a command per match (like the wc -l and prettier examples above), or pipe fd’s output into xargs for batch work — the same pattern I covered in the find -exec post.

How do I install fd?

It ships as a single static binary. On macOS run brew install fd; on Linux use your package manager (apt install fd-find, where the binary is fdfind) or cargo install fd-find; on Windows it is on Scoop and Chocolatey.