Terminal GuideTerminal Guide
fd icon

fd

Modern CLI
macOSLinuxWindows
Rust

Simple, fast and user-friendly alternative to find.

Official Website

Features

FastRegex SupportSmart CaseParallel ExecutionGitignore Aware
Replaces
find

Installation

Homebrew
brew install fd
APT (Debian/Ubuntu)
apt install fd-find
Pacman (Arch)
pacman -S fd
Cargo (Rust)
cargo install fd-find

Why 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

Basic Commands
# 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

$ fd component
src/components/Button.tsx
src/components/Header.tsx
src/components/Footer.tsx
src/components/ui/ComponentList.tsx

Color output makes it easy to distinguish directories from filenames.

Common Options

OptionDescriptionExample
-e, --extensionFilter by extensionfd -e rs
-t, --typeFilter by file type (f: file, d: directory, l: symlink)fd -t d config
-H, --hiddenAlso search hidden filesfd -H .env
-I, --no-ignoreIgnore .gitignorefd -I node_modules
-d, --max-depthLimit search depthfd -d 2 readme
-x, --execExecute command for each resultfd -e txt -x wc -l
-X, --exec-batchPass all results together to commandfd -e py -X black
-s, --case-sensitiveCase sensitive matchingfd -s README
-g, --globUse glob patterns instead of regexfd -g '*.test.js'
-p, --full-pathMatch full pathfd -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.

Smart Case Behavior
# 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.rst

Regex Patterns

Regex Examples
# 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 f

Glob Patterns

Glob Pattern Examples
# 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 Patterns
# 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 js

Command Execution (-x / -X)

Command Execution
# 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 -n

Hidden Files and Exclusions

Hidden File Search
# 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 js

Integration with Other Tools

Pipeline
# 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.

~/.config/fd/ignore
# Build artifacts
dist/
build/
target/

# Dependencies
node_modules/
vendor/
.venv/

# IDE settings
.idea/
.vscode/

# Cache
*.cache
.cache/
__pycache__/

Shell Alias Configuration

~/.bashrc or ~/.zshrc
# 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

Environment Variable Configuration
# 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

Taskfindfd
Search by filenamefind . -name '*pattern*'fd pattern
Search by extensionfind . -name '*.js'fd -e js
Directories onlyfind . -type d -name 'config'fd -t d config
Depth limitfind . -maxdepth 2 -name '*.md'fd -d 2 -e md
Execute commandfind . -name '*.txt' -exec rm {} \;fd -e txt -x rm
Batch executionfind . -name '*.py' -exec black {} +fd -e py -X black
Exclusionfind . -name '*.js' -not -path '*/node_modules/*'fd -e js (auto-excluded)
Regexfind . -regex '.*test.*\.js$'fd 'test.*\.js$'
Size filterfind . -size +1Mfd -S +1m
Modification timefind . -mtime -1fd --changed-within 1d

Feature Comparison

Featurefindfd
SpeedNormalFast (parallel processing)
SyntaxComplexSimple
gitignore support-Supported by default
Color output-Enabled by default
Smart case-Supported
RegexLimitedDefault
Parallel command execution- (requires xargs)Built-in
POSIX compatibleSupported-
Standard installationAlmost all environmentsSeparate installation

Tips

  • *On Ubuntu, it's installed as the fd-find package with command name fdfind. Setting alias fd=fdfind is convenient
  • *Use -j option 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-within and --changed-before (e.g., 1d, 2weeks, 3months)
  • *In shell scripts, use -0 option for NULL-delimited output to safely handle filenames with spaces
  • *Use --list-details or -l option to display detailed information like ls -l
Written by Dai AokiPublished: 2026-01-20

Related Articles

Explore More