fd is a “simple, fast, and user-friendly alternative to find”.
This neat tool offers a more intuitive syntax for finding files and operating on them. The author wrote fd
in Rust. Thus, it’s quite fast.
Let’s say we want to find all mp3
files in a directory. With find
, you have to do something like this:
find -name "*.mp3"
fd
looks simpler:
fd -e mp3
Here’s an example command that converts all jpg
files to png
files:
fd -e jpg -x convert {} {.}.png
Here are all the options for the fd
command:
USAGE:
fd [FLAGS/OPTIONS] [<pattern>] [<path>...]
FLAGS:
-H, --hidden Search hidden files and directories
-I, --no-ignore Do not respect .(git|fd)ignore files
--no-ignore-vcs Do not respect .gitignore files
-s, --case-sensitive Case-sensitive search (default: smart case)
-i, --ignore-case Case-insensitive search (default: smart case)
-g, --glob Glob-based search (default: regular expression)
-F, --fixed-strings Treat the pattern as a literal string
-a, --absolute-path Show absolute instead of relative paths
-L, --follow Follow symbolic links
-p, --full-path Search full path (default: file-/dirname only)
-0, --print0 Separate results by the null character
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-d, --max-depth <depth> Set maximum search depth (default: none)
-t, --type <filetype>... Filter by type: file (f), directory (d), symlink (l),
executable (x), empty (e)
-e, --extension <ext>... Filter by file extension
-x, --exec <cmd> Execute a command for each search result
-X, --exec-batch <cmd> Execute a command with all search results at once
-E, --exclude <pattern>... Exclude entries that match the given glob pattern
-c, --color <when> When to use colors: never, *auto*, always
-S, --size <size>... Limit results based on the size of files.
--changed-within <date|dur> Filter by file modification time (newer than)
--changed-before <date|dur> Filter by file modification time (older than)
ARGS:
<pattern> the search pattern: a regular expression unless '--glob' is used (optional)
<path>... the root directory for the filesystem search (optional)
How To Install On Linux
fd
offers myriad ways of installing.
Debian/Ubuntu:
sudo apt-get install fd-find
Arch Linux:
pacman -S fd
How to Install on MacOS
brew install fd
or
sudo port install fd