Skip to main content

Type and Extension Filtering

fd provides streamlined, easy-to-remember flags for basic metadata filtering, avoiding the verbose syntax of find.

1. Type Filtering (-t, --type)

To restrict your search to specific filesystem objects, use -t followed by a single character.

FlagMeaningUse Case
-t fFileRegular files (documents, scripts)
-t dDirectoryFolders
-t lSymlinkShortcuts
-t xExecutableBinaries or scripts with the +x bit set
-t eEmptyFiles with 0 bytes, or directories with no children

Examples:

# Find only directories containing "api"
fd -t d api

# Find all empty files in the current directory
fd -t e -t f

Notice you can chain -t flags to combine logic. -t e -t f means "Type is Empty AND Type is File".

2. Extension Filtering (-e, --extension)

In find, searching for multiple file extensions requires complex grouping: find . -type f \( -name "*.js" -o -name "*.ts" -o -name "*.jsx" \)

In fd, the -e flag handles this natively and elegantly. You do not need to include the dot (.).

# Find all javascript files
fd -e js

# Find JS, TS, and JSX files
fd -e js -e ts -e jsx

Combining Patterns and Extensions

The -e flag filters the results of your search pattern.

# Find files containing "auth" that are specifically Python files
fd auth -e py

This is significantly faster than using a regex pattern like fd "auth.*\.py$", because fd's internal engine can optimize extension checks differently than full regex evaluation.