LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

fd-type

Filter an fd search by file type

TLDR

Regular files only
$ fd --type file [pattern]
copy
The same filter in its short form
$ fd -t f [pattern]
copy
Directories
$ fd -t d [pattern]
copy
Symbolic links
$ fd -t l [pattern]
copy
Executable files
$ fd -t x
copy
Empty files
$ fd -t e -t f
copy
Empty directories
$ fd -t e -t d
copy
Files and symlinks together
$ fd -t f -t l [pattern]
copy
Block devices
$ fd -t b
copy

SYNOPSIS

fd [-t|--type filetype]... [options] [pattern] [path...]

DESCRIPTION

fd --type (short -t) restricts a search with the fd file finder to one or more entry types. There is no separate fd-type binary. On Debian and Ubuntu the same program is often installed as fdfind, and the flag is the same: fdfind -t f.Hidden entries and gitignore patterns stay out of the results unless you pass --hidden or --no-ignore. The search pattern is still a regex matched against the file name, not a glob, unless you pass --glob.Repeat the flag to combine types. --type file --type symlink prints regular files and symbolic links. executable works differently: --type executable implies regular files, so it does not also list directories that happen to be executable. empty matches empty files and empty directories until you add file or directory beside it.

PARAMETERS

-t filetype, --type filetype

Keep entries of this type. Repeat the flag to include more than one type. Short forms may be joined to the letter (-tf, -td).
f, file
Regular files
d, dir, directory
Directories
l, symlink
Symbolic links
b, block-device
Block devices
c, char-device
Character devices
s, socket
Sockets
p, pipe
Named pipes (FIFOs)
x, executable
Executable files. Implies file
e, empty
Empty files and empty directories, unless file or directory is also set

INSTALL

sudo apt install fd-find
copy
sudo dnf install fd-find
copy
sudo pacman -S fd
copy
sudo apk add fd
copy
sudo zypper install fd
copy
brew install fd
copy
nix profile install nixpkgs#fd
copy

CAVEATS

Type the flag on fd or fdfind. There is no fd-type command. executable implies file. empty covers both empty files and empty directories until you narrow it. A default search still skips hidden paths and does not follow symlinked directories, so device nodes, sockets, and pipes are easy to miss under /dev without --hidden and a path.

SEE ALSO

fd(1), fdfind(1), find(1)

RESOURCES

Copied to clipboard
Kai