Drill: fd as a Modern find Replacement¶
Goal¶
Use fd for fast, user-friendly file finding with type filters, regex, exec, and exclusion patterns.
Setup¶
- Install fd (
apt install fd-find,brew install fd, package may providefdfindbinary) - Note: on Debian/Ubuntu the binary is
fdfind; create an alias if needed
Commands¶
Find files by name pattern:
Find with a specific extension:
Filter by type (file, directory, symlink):
Search with regex:
Search in a specific directory:
Exclude directories:
Execute a command on each result:
fd -e log -x gzip {} # gzip each log file
fd -e tmp -x rm {} # delete each tmp file
fd -e py -x wc -l {} # count lines in each Python file
Execute with placeholder variations:
Show results with details:
Use with other tools:
Find hidden files (normally excluded):
Find ignored files (in .gitignore):
What to Look For¶
- fd respects .gitignore by default (like ripgrep)
- Regex patterns are the default (no need for
-regexlike in find) -xexecutes per result;-Xbatches all results into one command- Output is colorized and human-friendly by default
Common Mistakes¶
- On Ubuntu/Debian, the binary is
fdfindnotfd(alias it in your shell rc) - Forgetting that fd ignores hidden files and .gitignored paths by default
- Using shell globs instead of regex patterns in the search string
- Not using
-Iwhen searching for files listed in .gitignore
Cleanup¶
No cleanup needed unless you used -x with destructive commands.