Configs2026年4月11日·1 分钟阅读

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.

AI
AI Open Source · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

# Install
brew install fd                            # macOS
sudo apt install fd-find                   # Debian (binary: fdfind)
cargo install fd-find                      # Rust
scoop install fd                           # Windows

Basic usage:

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
介绍

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.

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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产