What fd Does
- Regex matching — default,
--globfor glob patterns - Gitignore aware — respects .gitignore by default
- Colored output — file type colors via LS_COLORS
- Parallel traversal — multi-threaded walking
- Exec commands —
-xor-Xto run commands on matches - Smart case — case-insensitive when pattern is all lowercase
- File type filter —
-t ffile,-t ddir,-t llink - Time filters — changed-within, changed-before
- Size filters —
--size +1M
Architecture
Single Rust binary using walkdir + ignore crates for traversal. Runs on multiple threads (one per CPU). Uses Rust regex engine for pattern matching.
Self-Hosting
CLI tool.
Key Features
- ~5x faster than find on average
- Smart defaults (gitignore, smart case, colors)
- Simple intuitive syntax
- Parallel traversal
- Integration with xargs via
-x/-X - Unicode aware
- Size and time filters
Comparison
| Tool | Language | Smart Defaults | Syntax |
|---|---|---|---|
| fd | Rust | Yes | Intuitive |
| find | C | None | POSIX verbose |
| fdupes | C | Dup focus | Specialized |
| ripgrep + --files | Rust | Yes | Different focus |
常见问题 FAQ
Q: Ubuntu 上叫 fdfind?
A: 是的,命名冲突。alias 一下 alias fd=fdfind 即可。
Q: 和 find 比快多少? A: 一般 3-10 倍。大仓库差距更大,因为 fd 并行且跳过 .gitignore。
Q: 删除所有匹配?
A: fd -t f pattern -x rm。加 -0 | xargs -0 rm 更安全(空格/换行处理正确)。
来源与致谢 Sources
- GitHub: https://github.com/sharkdp/fd
- License: Apache 2.0 / MIT