FD(1) | General Commands Manual | FD(1) |
fd - find entries in the filesystem
fd [-HIEsiaLp0hV] [-d depth] [-t filetype] [-e ext] [-E exclude] [-c when] [-j num] [-x cmd] [pattern] [path...]
fd is a simple, fast and user-friendly alternative to find(1).
By default fd uses regular expressions for the pattern. However, this can be changed to use simple glob patterns with the '--glob' option.
By default fd will exclude hidden files and directories, as well as any files that match gitignore rules or ignore rules in .ignore or .fdignore files. For convenenience, '.git' is treated as if it was always included in gitignore rules. These files can be included with options such as
Examples:
- Only search for files:
fd --type file …
fd -tf …
- Find both files and symlinks
fd --type file --type symlink …
fd -tf -tl …
- Find executable files:
fd --type executable
fd -tx
- Find empty files:
fd --type empty --type file
fd -te -tf
- Find empty directories:
fd --type empty --type directory
fd -te -td
If you want to search for files without extension, you can use the regex '^[^.]+$' as a normal search pattern.
If neither '+' nor '-' is specified, file size must be exactly equal to this.
Examples:
--changed-within 2weeks
--change-newer-than "2018-10-27 10:00:00"
--newer 2018-10-27
Examples:
--changed-before "2018-10-27 10:00:00"
--change-older-than 2weeks
Examples:
--owner john
--owner :students
--owner "!john:students"
Note that all subsequent positional arguments are considered to be arguments to the command - not to fd. It is therefore recommended to place the -x/--exec option last. Alternatively, you can supply a ';' argument to end the argument list and continue with more fd options. Most shells require ';' to be escaped: '\;'. This option can be specified multiple times, in which case all commands are run for each file found, in the order they are provided. In that case, you must supply a ';' argument for all but the last commands.
If parallelism is enabled, the order commands will be executed in is non-deterministic. And even with --threads=1, the order is determined by the operating system and may not be what you expect. Thus, it is recommended that you don't rely on any ordering of the results.
The following placeholders are substituted before the command is executed:
If no placeholder is present, an implicit "{}" at the end is assumed.
Notice that you can use "{{" and "}}" to escape "{" and "}" respectively, which is especially useful if you need to include the literal text of one of the above placeholders.
Examples:
- find all *.zip files and unzip them:
fd -e zip -x unzip
- find *.h and *.cpp files and run "clang-format -i .." for each of
them:
fd -e h -e cpp -x clang-format -i
- Convert all *.jpg files to *.png files:
fd -e jpg -x convert {} {.}.png
The order of the arguments is non-deterministic and should not be relied upon.
One of the following placeholders is substituted before the command is executed:
If no placeholder is present, an implicit "{}" at the end is assumed.
Like --exec, this can be used multiple times, in which case each command will be run in the order given.
Examples:
- Find all test_*.py files and open them in your favorite editor:
fd -g 'test_*.py' -X vim
Note that this executes a single "vim" process with all search
results as arguments.
- Find all *.rs files and count the lines with "wc -l ...":
fd -e rs -X wc -l
The regular expression syntax used by fd is documented here:
https://docs.rs/regex/1.0.0/regex/#syntax
The glob syntax is documented here:
https://docs.rs/globset/#syntax
Bugs can be reported on GitHub: https://github.com/sharkdp/fd/issues
find(1)