← Back to archive

Repo of the Day

sharkdp/fd

Published: Jun 6, 2023

Open repository ↗

A simple, fast and user-friendly alternative to 'find'. Written in Rust

Summary

fd is a command-line tool written in Rust that searches the filesystem. The README describes it as "a simple, fast and user-friendly alternative to find" that uses sensible defaults rather than mirroring find's full feature set.

What it is useful for

fd replaces the common find patterns engineers reach for daily. Search patterns are treated as regular expressions by default, with smart case (case-insensitive unless the pattern contains an uppercase letter). Results can be filtered by extension (-e md), file type (-t f for files, -td for directories), size, owner, and modification time. Hidden files and .gitignore patterns are skipped unless you pass -H, -I, or -u. fd can also execute commands on results: -x runs a command per result in parallel, and -X runs once with all results as arguments. Placeholders like {}, {.}, {/}, {//}, and {/.} work similarly to GNU Parallel.

How engineers can use it

Start with simple substring search: fd netfl recurses from the current directory. Add a regex: fd '^x.*rc$' /etc. Restrict by extension: fd -e rs mod finds Rust files whose name contains mod. Use a glob when you want literal matching: fd -g libc.so /usr. Pipe to other tools with null separators: fd -0 -e rs | xargs -0 wc -l. Replace fzf's default finder with export FZF_DEFAULT_COMMAND='fd --type file --follow --hidden --exclude .git'. Format results as a tree via fd --extension rs | tree --fromfile. Run per-file actions with fd -e jpg -x convert {} {.}.png, or batch actions with fd -e cpp -e h -X rg 'std::cout'.

Install via your distribution's package manager. On Debian/Ubuntu: apt install fd-find (the binary installs as fdfind; the README recommends ln -s $(which fdfind) ~/.local/bin/fd). On Fedora: dnf install fd-find. On Arch: pacman -S fd. On Alpine: apk add fd. Additional platforms (macOS, Windows) and other distributions are documented in the README.

Documented limitations: fd does not aim to match all of find's functionality. Shell aliases and functions cannot be used with -x/-X. Regex metacharacters must be shell-quoted. Patterns beginning with a dash need -- before them. By default fd matches filenames rather than full paths (use -p). When a search returns no results, the README points readers to the troubleshooting section.