fd
Simple, fast and user-friendly alternative to find.
Official WebsiteFeatures
findInstallation
brew install fdapt install fd-findpacman -S fdcargo install fd-findWhy Use fd?
fd is designed as an alternative to the traditional find command, offering a fast and user-friendly file search tool. No need to memorize complex syntax - search files intuitively.
Ultra-Fast Search
Written in Rust with parallel processing support. Often 5x+ faster than find, comfortable searching even in large codebases.
Simple Syntax
No need to memorize find's complex options. Just fd pattern to start searching.
gitignore Support
Respects .gitignore by default. Automatically excludes node_modules and build artifacts.
Parallel Command Execution
Execute commands in parallel on search results. Process large amounts of files quickly.
Basic Usage
Simple Search
# Search files matching a pattern
fd readme
# Search in a specific directory
fd config /etc
# Search by extension
fd -e py
# Search with regex (default)
fd '^test.*\.js$'Output Example
Color output makes it easy to distinguish directories from filenames.
Common Options
| Option | Description | Example |
|---|---|---|
-e, --extension | Filter by extension | fd -e rs |
-t, --type | Filter by file type (f: file, d: directory, l: symlink) | fd -t d config |
-H, --hidden | Also search hidden files | fd -H .env |
-I, --no-ignore | Ignore .gitignore | fd -I node_modules |
-d, --max-depth | Limit search depth | fd -d 2 readme |
-x, --exec | Execute command for each result | fd -e txt -x wc -l |
-X, --exec-batch | Pass all results together to command | fd -e py -X black |
-s, --case-sensitive | Case sensitive matching | fd -s README |
-g, --glob | Use glob patterns instead of regex | fd -g '*.test.js' |
-p, --full-path | Match full path | fd -p 'src/.*test' |
Regex and Patterns
Smart Case
fd uses "smart case" by default. If the pattern is all lowercase, it's case-insensitive; if it contains uppercase, it's case-sensitive.
# Case-insensitive (pattern is all lowercase)
fd readme
# Matches README.md, readme.txt, Readme.rst
# Case-sensitive (contains uppercase)
fd README
# Matches README.md only
# Explicitly case-sensitive
fd -s readme
# Matches readme.txt only
# Explicitly case-insensitive
fd -i README
# Matches README.md, readme.txt, Readme.rstRegex Patterns
# Files starting with a digit
fd '^[0-9]'
# Files ending with .test.js or .spec.js
fd '\.(test|spec)\.js$'
# Files without specific characters
fd '^[^_].*\.py$'
# Filenames with length of 5 characters or less
fd '^.{1,5}$' -t fGlob Patterns
# Use glob patterns (-g option)
fd -g '*.md'
fd -g '**/*.test.js'
fd -g 'config.{json,yaml,toml}'
# Convenient when more intuitive than regex
fd -g 'component-*.tsx'Practical Usage Examples
File Search and Filtering
# Search recently modified files
fd -e rs --changed-within 1d
# Files of specific size or larger
fd -S +1m -t f
# Search for empty directories
fd -t d -t e
# Search for executable files
fd -t x
# Exclude specific directories
fd -E node_modules -E .git -e jsCommand Execution (-x / -X)
# Execute command for each file (parallel)
fd -e jpg -x convert {} {.}.png
# Placeholder descriptions:
# {} - Full path (path/to/file.ext)
# {.} - Without extension (path/to/file)
# {/} - Filename only (file.ext)
# {//} - Directory path (path/to)
# {/.} - Filename (no extension) (file)
# Format all Python files (batch)
fd -e py -X black
# Open search results in editor
fd -e md -X code
# Count lines in files
fd -e rs -x wc -l {} \; | sort -nHidden Files and Exclusions
# Include hidden files in search
fd -H .bashrc
# Ignore .gitignore
fd -I node_modules
# Enable both (search all files)
fd -HI cache
# Exclude specific files/directories
fd -E '*.min.js' -E 'dist/' -e jsIntegration with Other Tools
# Combine with fzf for interactive selection
fd -t f | fzf --preview 'bat --color=always {}'
# Combine with ripgrep
fd -e py | xargs rg "import"
# Execute complex commands with xargs
fd -e log -x gzip {}
# Search untracked files with git
fd -t f --no-ignore-vcs | grep -v ".git"Configuration and Customization
Global Ignore File
Configure patterns to globally exclude in ~/.config/fd/ignore.
# Build artifacts
dist/
build/
target/
# Dependencies
node_modules/
vendor/
.venv/
# IDE settings
.idea/
.vscode/
# Cache
*.cache
.cache/
__pycache__/Shell Alias Configuration
# fd alias configuration
alias f='fd'
# Search including hidden files
alias fa='fd -H'
# Search all files (ignore ignore)
alias fA='fd -HI'
# Search directories only
alias fdir='fd -t d'
# Search files only
alias ffile='fd -t f'
# fzf integrated search
fzf-fd() {
fd -t f "$@" | fzf --preview 'bat --color=always {}'
}
# Search and edit files
fe() {
local file
file=$(fd -t f | fzf --preview 'bat --color=always {}')
[ -n "$file" ] && ${EDITOR:-vim} "$file"
}Environment Variables
# Set default options (not recommended, shell aliases preferred)
# fd supports command-line arguments only
# Use fd as default command for fzf
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND='fd --type d --hidden --follow --exclude .git'Comparison with find
| Task | find | fd |
|---|---|---|
| Search by filename | find . -name '*pattern*' | fd pattern |
| Search by extension | find . -name '*.js' | fd -e js |
| Directories only | find . -type d -name 'config' | fd -t d config |
| Depth limit | find . -maxdepth 2 -name '*.md' | fd -d 2 -e md |
| Execute command | find . -name '*.txt' -exec rm {} \; | fd -e txt -x rm |
| Batch execution | find . -name '*.py' -exec black {} + | fd -e py -X black |
| Exclusion | find . -name '*.js' -not -path '*/node_modules/*' | fd -e js (auto-excluded) |
| Regex | find . -regex '.*test.*\.js$' | fd 'test.*\.js$' |
| Size filter | find . -size +1M | fd -S +1m |
| Modification time | find . -mtime -1 | fd --changed-within 1d |
Feature Comparison
| Feature | find | fd |
|---|---|---|
| Speed | Normal | Fast (parallel processing) |
| Syntax | Complex | Simple |
| gitignore support | - | Supported by default |
| Color output | - | Enabled by default |
| Smart case | - | Supported |
| Regex | Limited | Default |
| Parallel command execution | - (requires xargs) | Built-in |
| POSIX compatible | Supported | - |
| Standard installation | Almost all environments | Separate installation |
Tips
- *On Ubuntu, it's installed as the
fd-findpackage with command namefdfind. Settingalias fd=fdfindis convenient - *Use
-joption to limit parallel execution threads (e.g.,fd -j 4 -x ...) - *Combine with fzf for powerful interactive file search
- *Time-based filtering is possible with
--changed-withinand--changed-before(e.g., 1d, 2weeks, 3months) - *In shell scripts, use
-0option for NULL-delimited output to safely handle filenames with spaces - *Use
--list-detailsor-loption to display detailed information like ls -l