LinuxCommandLibrary

fd

Find entries in your filesystem

TLDR

Recursively find files matching a specific pattern in the current directory

$ fd "[string|regex]"
copy

Find files that begin with a specific string
$ fd "[^string]"
copy

Find files with a specific extension
$ fd [[-e|--extension]] [txt]
copy

Find files in a specific directory
$ fd "[string|regex]" [path/to/directory]
copy

Include ignored and hidden files in the search
$ fd [[-H|--hidden]] [[-I|--no-ignore]] "[string|regex]"
copy

Exclude files that match a specific regex
$ fd [string] [[-E|--exclude]] [regex]
copy

Execute a command on each search result returned
$ fd "[string|regex]" [[-x|--exec]] [command]
copy

Find files only in the current directory
$ fd [[-d|--max-depth]] 1 "[string|regex]"
copy

SYNOPSIS

fd [OPTIONS] [<pattern>] [<path> ...]

PARAMETERS

-H, --hidden
    Search hidden files and directories

-t, --type
    Limit to file types: file, dir, symlink, empty, executable

-e, --extension
    Match files by extension (e.g., rs)

-E, --exclude
    Exclude paths matching the glob pattern

-g, --glob
    Match against glob patterns instead of regex

-p, --absolute-path
    Display absolute paths

-x, --exec ;
    Execute command for each match

--max-depth
    Limit search depth

-I, --no-ignore
    Disable ignore files (.gitignore, etc.)

--color
    Control color output: always, never, auto

-0, --null
    Separate results with NUL byte

-F, --fixed-strings
    Disable regex; treat pattern as literal string

DESCRIPTION

fd is a simple, fast, and user-friendly command-line tool designed as an alternative to the traditional Unix find utility.

It prioritizes speed through parallel directory traversal and smart filtering, often outperforming find in common scenarios. Key features include:
• Intuitive syntax: search by name, extension, or type without complex expressions.
• Automatic respect for .gitignore, .git, .hg, and .fdignore files to skip irrelevant paths.
• Colorized output by default for better readability.
• Hidden file support with -H, file type filtering with -t, and extension matching with -e.
• Globbing patterns and regex support.
• Exec action with -x to run commands on matches.

Ideal for developers, fd simplifies file searching in large codebases, ignoring build artifacts and version control files out-of-the-box. It's written in Rust for safety and performance, with minimal dependencies.

CAVEATS

Not installed by default; requires package manager (e.g., apt install fd-find) or Cargo. Case-insensitive by default on case-insensitive filesystems; behavior differs from find in regex and defaults.

EXAMPLES

fd .rs        Find all Rust files
fd -t dir test  Find directories named 'test'
fd -e md -x pandoc {} -o {}.pdf  Convert Markdown files

INSTALLATION

Linux: sudo apt install fd-find (Debian/Ubuntu)
macOS: brew install fd
From source: cargo install fd-find

HISTORY

Developed by David Peter (sharkdp) starting 2017. Written in Rust for performance. First stable release 7.0 in 2018; now at v10+. Actively maintained with 30k+ GitHub stars.

SEE ALSO

find(1), rg(1), ag(1), locate(1)

Copied to clipboard