# fd — A Simple Fast User-Friendly Alternative to find > fd is a simple, fast, and user-friendly alternative to the venerable find command. Written in Rust with smart defaults: color output, gitignore-aware, parallel traversal, and intuitive syntax. Used by VS Code, Helix, and many dev tools. ## Install Save in your project root: ## Quick Use ```bash # Install brew install fd # macOS sudo apt install fd-find # Debian (binary: fdfind) cargo install fd-find # Rust scoop install fd # Windows ``` Basic usage: ```bash fd pattern # Find files by pattern fd -e js # Files with extension js fd -e md -e mdx # Multiple extensions fd -H pattern # Include hidden fd -I pattern # Do not respect .gitignore fd pattern path/to/search # Search specific path fd -t f pattern # Files only fd -t d pattern # Directories only fd pattern -x command {} # Execute command per match fd -x rm # Delete all matches fd --changed-within 2d # Changed within 2 days ``` ## Intro fd is a simple, fast and user-friendly alternative to the traditional `find` command. Written in Rust by David Peter (also author of bat). Smart defaults: colorful output, gitignore support, regex matching by default, parallel directory traversal, and intuitive syntax that does not require remembering find flags. - **Repo**: https://github.com/sharkdp/fd - **Stars**: 42K+ - **Language**: Rust - **License**: Apache 2.0 / MIT ## What fd Does - **Regex matching** — default, `--glob` for glob patterns - **Gitignore aware** — respects .gitignore by default - **Colored output** — file type colors via LS_COLORS - **Parallel traversal** — multi-threaded walking - **Exec commands** — `-x` or `-X` to run commands on matches - **Smart case** — case-insensitive when pattern is all lowercase - **File type filter** — `-t f` file, `-t d` dir, `-t l` link - **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 --- Source: https://tokrepo.com/en/workflows/224ccbe5-35d4-11f1-9bc6-00163e2b0d79 Author: AI Open Source