Fd Cheatsheet
Syntax Reminder
fd [FLAGS] [PATTERN] [PATH]
Pattern is regex by default. PATH defaults to . if omitted.
Core Searching
| Goal | Command |
|---|---|
| Basic search (regex) | fd pattern |
| Search specific dir | fd pattern /var/log |
| Glob mode (like find) | fd -g "*.conf" |
| Literal string | fd -F "192.168.1.1" |
| Case sensitive | fd -s pattern |
| Case insensitive | fd -i Pattern |
Scope Control (Ignore Ladder)
| Goal | Command |
|---|---|
| Include hidden files | fd -H pattern |
Ignore .gitignore | fd -I pattern |
| Search EVERYTHING | fd -uu pattern |
| Exclude a path | fd -E node_modules pattern |
| Max depth | fd -d 2 pattern |
Type and Extension
| Goal | Command |
|---|---|
| Files only | fd -t f |
| Directories only | fd -t d |
| Executables | fd -t x |
| Empty files | fd -t e -t f |
| By extension | fd -e py |
| Multiple extensions | fd -e js -e ts -e jsx |
Size and Time
| Goal | Command |
|---|---|
| Larger than 1 GB | fd -S +1g |
| Smaller than 10 MB | fd -S -10m |
| Changed this week | fd --changed-within 1w |
| Older than 1 month | fd --changed-before 1mo |
Execution
| Goal | Command |
|---|---|
| Run per file (parallel) | fd -e jpg -x chmod 644 |
| Run once for all (batch) | fd -e js -X eslint |
| Limit parallelism | fd -x cmd -j 1 |
{} Placeholders
| Placeholder | Value | Example |
|---|---|---|
{} | Full path | ./src/main.rs |
{/} | Basename | main.rs |
{//} | Parent dir | ./src |
{.} | Path no ext | ./src/main |
{/.} | Basename no ext | main |
Output Formatting
| Goal | Command |
|---|---|
| Absolute paths | fd pattern -a |
| Long format (ls -l) | fd pattern -l |
| Null-delimited | fd pattern -0 |
Strip ./ prefix | fd --strip-cwd-prefix |
Ready-to-Paste Pipelines
# Find and replace in all Python files
fd -e py -0 | xargs -0 sed -i 's/old_func/new_func/g'
# Batch convert audio files
fd -e flac -x ffmpeg -i {} -b:a 320k {.}.mp3
# Delete all __pycache__ directories
fd __pycache__ -t d -X rm -rf
# Zip all config files
fd -e conf -X zip configs.zip
# Open a file interactively with fzf
fd -t f | fzf | xargs vim