Skip to main content

Smart Case Logic

One of fd's best ergonomic features is its "Smart Case" search algorithm. It dynamically determines whether your search should be case-sensitive or case-insensitive based entirely on the characters you type.

This eliminates the need to constantly remember to use -i (or -iname in find).

The Smart Case Rules

  1. All Lowercase = Case Insensitive If your search pattern contains only lowercase letters, fd assumes you are doing a broad search and automatically performs a case-insensitive search.

    # You type:
    fd readme

    # fd matches:
    # readme.md
    # README.txt
    # ReadMe.html
  2. Any Uppercase = Case Sensitive If your search pattern contains at least one uppercase letter, fd assumes you know exactly what you are looking for, and automatically switches to a case-sensitive search.

    # You type:
    fd Readme

    # fd matches ONLY:
    # Readme.md
    # Readme.txt
    # (It will NOT match README or readme)

Overriding Smart Case

There are situations where the Smart Case algorithm guesses wrong. For example, you might want to perform a strict case-sensitive search for a lowercase string, ensuring you don't match uppercase variants.

You can explicitly override the behavior using flags:

Force Case Sensitive (-s, --case-sensitive)

# Finds ONLY "config.json" (strict lowercase)
# Will NOT find "Config.json" or "CONFIG.JSON"
fd -s config.json

Force Case Insensitive (-i, --ignore-case)

# Finds "DockerFile", "Dockerfile", "dockerfile", etc.
# (Even though the pattern contains an uppercase 'D', -i overrides it)
fd -i Dockerfile
Why this matters

Smart case is a feature adopted from modern code editors like Vim and VS Code. It is designed to minimize cognitive load. You can usually just type in lowercase and find what you need rapidly, only capitalizing when precision is required.