Posted on
Software

fd: Fast alternative to `find`

Author
  • User
    Linux Bash
    Posts by this author
    Posts by this author

fd: A Faster, User-Friendly Alternative to find on Linux

When it comes to searching for files in Linux, the find command is indeed powerful and flexible but can be intricate for beginners, and sometimes slow with its vast range of options and expressions. Here, we introduce fd, a simple, fast, and user-friendly alternative that enhances file searching on Unix-like systems, leveraging modern Rust-based implementations.

Features of fd

  • Fast performance: It leverages multi-threaded operations to expedite the search process.

  • Simple syntax: The syntax is more straightforward and easier to remember, focusing on usability.

  • Ignores hidden directories and files by default: Streamlines results by ignoring entries that you often don't need.

  • Smart case: Search is case-insensitive by default, but switches to case-sensitive if the search string includes uppercase characters.

  • Regular expression (regex) support: Defaults to regex searches making complex searches simpler.

  • Colorized output: The results are colorized by default, highlighting different types of files like directories, files, and links.

  • Integration with other tools: Native compatibility with the output of other commands (xargs, fd -X, etc.).

Installing fd

On Ubuntu and Debian-Based Systems

fd is readily available for installation via apt. First, update your package index:

sudo apt update

Then install fd:

sudo apt install fd-find

Due to potential naming conflicts, the binary on Debian-based systems is named fdfind. You can create an alias to make usage similar to other distributions:

alias fd=fdfind

To make this alias permanent, add it to your shell's configuration file (e.g., ~/.bashrc).

On Fedora, CentOS, and RHEL

For systems that use dnf, installation is straightforward:

sudo dnf install fd-find

Here, the binary is named fd already, so no alias is needed.

On openSUSE

fd is available through zypper:

sudo zypper install fd

On Arch Linux

Use pacman to install fd:

sudo pacman -S fd

Using Homebrew (Linux and macOS)

Alternatively, if you're on a system with Homebrew:

brew install fd

Common Usage Scenarios

Basic Searching

To search for files with "config" in their name in the current directory:

fd config

Specify the Search Directory

To search in a different directory:

fd config /etc

Search by File Extension

To find all .txt files:

fd -e txt

Combining with Other Commands

You can easily use fd's output with other tools. For example, to count lines in Python files:

fd -e py -x wc -l

Displaying Only Directories

To filter search results to include only directories:

fd -t d config

Conclusion

For many users, fd offers an ideal mix of speed, simplicity, and power for everyday file search tasks, potentially replacing find in common usage scenarios. Its sensible defaults and fast performance make it a valuable tool in any Linux user's arsenal. Whether you're a developer, system administrator, or just a Linux enthusiast, adding fd to your toolkit can enhance your productivity and streamline your workflows.