fd Cheatsheet
fd is a lightning-fast Rust-based file search tool, a modern replacement for the traditional find command. Uses regex by default, automatically respects .gitignore and hidden files, supports extension, time, and size filtering with parallel command execution. 43K+ GitHub Stars.
Quick Start
``bash
fd 'config.json' # Search by filename (regex)
fd -e py # Find all Python files
fd -t d 'src' # Find directories named src
fd -H '.env' # Include hidden files
fd -e log -x rm # Delete all log files
fd --changed-within 1week # Files modified in the last week
`
Basic Search
Search files and directories by name using regex patterns. fd is case-insensitive by default and searches recursively from the current directory.
`bash
fd 'config.json' # Regex search for matching filenames
fd -s 'Config' # Case-sensitive search
fd -i 'readme' # Explicit case-insensitive search
fd -g '*.log' # Glob pattern instead of regex
fd -d 3 'main' # Limit search to 3 levels deep
fd --search-path /var/log # Search from a specific root
fd --absolute-path 'config' # Output absolute paths
fd --full-path 'src/.*test' # Match against full path, not just filename
`
Filter Options
Powerful filtering by extension, file type, size, time, and exclusion patterns.
`bash
fd -e py # Only Python files
fd -t f 'config' # Files only (no directories)
fd -t d 'src' # Directories only
fd -t l 'link' # Symbolic links only
fd -E 'node_modules' -e js # Exclude node_modules
fd --size '+100MB' # Files larger than 100MB
fd --size '-1KB' # Files smaller than 1KB
fd --changed-within '1week' # Modified in the last week
fd --changed-before '2024-01-01' # Modified before a date
fd --changed-within '30min' # Modified in the last 30 minutes
`
Execute Commands
Run commands on search results with flexible placeholder syntax.
`bash
fd -e py -x wc -l # Count lines per Python file
fd -e jpg -x convert {} {.}.png # Convert JPG to PNG ({} = full path, {.} = no ext)
fd -e txt -X cat # Batch: cat all txt files at once
fd -e py --exec-batch chmod +x # Explicit batch exec
fd -e log --exec rm {} + # Parallel execution (like find -exec +)
fd -e mp3 -x mv {} /backup/ # Move files to backup dir
fd -0 -e py | xargs -0 wc -l # NUL-separated output for xargs
`
Advanced Options
Fine-tune fd's behavior with hidden files, symlinks, ignore rules, and parallelism.
`bash
fd -H '.env' # Include hidden and .gitignore'd files
fd -L 'data' # Follow symbolic links
fd --no-ignore 'secret' # Ignore .gitignore rules
fd --no-ignore-vcs 'config' # Ignore VCS ignore rules only
fd --no-ignore-parent 'output' # Don't read parent .gitignore
fd --color always 'pattern' # Force colored output
fd -j 8 -e py # Use 8 parallel threads
fd -0 -e py | xargs -0 wc -l # NUL-delimited output for xargs -0
`
Expert Tips
`bash
# Find large files (>100MB) modified in the last week
fd -H --size '+100MB' --changed-within '1week' -t f
# Bulk rename: replace spaces with underscores in all file names fd -g '* *' -x bash -c 'mv "$1" "${1// /_}"' _ {}
# Recursively count all lines in Python files fd -e py -X wc -l
# Copy all matching files to a target directory fd -e pdf -x cp {} /target/
# Interactive deletion with preview (using fzf) fd -e log -0 | fzf --read0 --multi | xargs -0 rm
# Find symlinks broken across the filesystem fd -t l -L -s -H . | while read -r link; do [ ! -e "$link" ] && echo "$link"; done ``
Basic Search(10)
| Command | Level | ||
|---|---|---|---|
fd --helpShow fd help | Basic | fd --help | |
fd PATTERNRecursively search files whose names match PATTERN | Basic | fd 'config.json' | |
fd -sCase-sensitive search (default is case-insensitive) | Basic | fd -s 'Config' | |
fd -iCase-insensitive search (explicit) | Basic | fd -i 'readme' | |
fd -g PATTERNUse glob pattern matching (not regex) | Intermediate | fd -g '*.log' | |
fd -HSearch hidden files and files ignored by .gitignore | Intermediate | fd -H '.env' | |
fd -d NLimit maximum search depth | Basic | fd -d 3 'main' | |
fd --full-pathMatch against full path (not just filename) | Intermediate | fd --full-path 'src/.*test' | |
fd --absolute-pathOutput absolute paths | Basic | fd --absolute-path 'config' | |
fd --search-path DIRSpecify search root directory | Basic | fd --search-path /var/log error.log |
Filter Options(8)
| Command | Level | ||
|---|---|---|---|
fd -e EXTFilter by file extension | Basic | fd -e py | |
fd -t fSearch files only (no directories) | Basic | fd -t f 'config' | |
fd -t dSearch directories only | Basic | fd -t d 'src' | |
fd -t lSearch symbolic links | Intermediate | fd -t l 'link' | |
fd -E PATTERNExclude files matching a pattern | Basic | fd -E 'node_modules' -e js | |
fd --changed-within DURATIONFind files changed within a duration | Intermediate | fd --changed-within '1week' -e md | |
fd --changed-before DURATIONFind files changed before a given time | Intermediate | fd --changed-before '2024-01-01' | |
fd --size SIZEFilter by file size | Intermediate | fd --size '+100MB' |
Execute(5)
| Command | Level | ||
|---|---|---|---|
fd PATTERN -x CMDExecute a command for each search result | Basic | fd -e py -x wc -l | |
fd PATTERN -x CMD {}Use {} placeholder for argument position | Intermediate | fd -e jpg -x convert {} {.}.png | |
fd PATTERN -X CMDBatch execute (all results as one invocation) | Intermediate | fd -e txt -X cat | |
fd PATTERN --exec-batch CMDExplicit batch execute with command | Intermediate | fd -e py --exec-batch chmod +x | |
fd PATTERN --exec CMD {} +Parallel execution (like find -exec +) | Expert | fd -e log --exec rm {} + |
Advanced(7)
| Command | Level | ||
|---|---|---|---|
fd -LFollow symbolic links | Intermediate | fd -L 'data' | |
fd --no-ignoreIgnore .gitignore rules | Intermediate | fd --no-ignore 'secret' | |
fd --no-ignore-vcsIgnore VCS ignore rules (keep .gitignore dir filtering) | Expert | fd --no-ignore-vcs 'config' | |
fd --no-ignore-parentDo not read parent directories' .gitignore | Expert | fd --no-ignore-parent 'output' | |
fd -0Separate output by NUL character (use with xargs -0) | Expert | fd -e py -0 | xargs -0 wc -l | |
fd --color alwaysForce colored output (even when piped) | Intermediate | fd --color always 'pattern' | |
fd -j NSet number of parallel threads | Intermediate | fd -j 8 -e py |