Posted on
Software

fd: Simplified and fast alternative to `find`

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

Discover fd: A Faster Alternative to the find Command in Linux

For Linux users, the find command is an invaluable tool for searching the filesystem for files and directories. However, it can sometimes be slow and its syntax might not always be the easiest to remember. Enter fd, a simple, fast, and user-friendly alternative to find that can significantly enhance your file searching tasks. In this blog post, we'll explore why fd might just be the tool you need to make your searches more efficient, and how to install it on different Linux distributions.

What is fd?

fd is a modern command-line utility primarily aimed at finding entries in your filesystem. It is written in Rust, renowned for its performance and safety features. fd has a more intuitive syntax than find, offers smart case-sensitive searching, and integrates colorized output and parallel command executions by default. Moreover, it respects your .gitignore files and can ignore hidden directories and patterns specified in global gitignore files.

Key Features of fd

  • Simpler and more modern syntax: You can use regular expressions or just simple substring search.

  • Fast performance: Searches are multithreaded and very fast compared to traditional find operations, especially on larger file systems.

  • Smart case sensitivity: fd defaults to case-insensitive searching when you type all letters in lowercase. If your query includes an uppercase letter, it switches to case-sensitive searching.

  • Colorized output: fd outputs results in a colorized format by default, making them more readable.

  • Respects .gitignore: Automatically respects .gitignore, .fdignore, and other ignore files, which helps in skipping unwanted files and directories.

Installing fd on Your Linux Distribution

1. Debian and Ubuntu (Using apt)

To install fd on Debian, Ubuntu, and other similar distributions, you first need to ensure that your package lists are updated, and then you can install using apt:

sudo apt update
sudo apt install fd-find

Note: In Debian/Ubuntu repositories, fd is packaged as fd-find.

2. Fedora, CentOS, and RHEL (Using dnf)

For those using Fedora or other RPM-based distributions like CentOS or RHEL, you can install fd using dnf:

sudo dnf install fd-find

3. openSUSE (Using zypper)

Users of openSUSE can install fd from their standard repositories using zypper:

sudo zypper install fd

Usage Examples

Here’s a quick look at some simple commands you can run with fd:

  • Find all files with 'config' in their name in the current directory:

    fd config
    
  • Search all .js files in a specific directory:

    fd -e js -H /path/to/directory
    
  • Execute a command on all found files (e.g., wc -l to count lines):

    fd -x wc -l
    

Conclusion

fd provides a compelling alternative to find, especially if you demand speed and a more friendly user interface. Its simplicity does not sacrifice power; it brings an enhanced toolset that invites users to perform complex file searching operations effortlessly. Whether you’re a seasoned system administrator or a curious beginner, fd is worth adding to your toolkit. Give it a try, and you might find yourself replacing find for most of your search tasks.