fd – A Simple and Fast Alternative to Find Command

Most of the Linux users are well familiar with the find command and the many cases it can be used. Today we are going to review an alternative to find command, called fd.

fd, is a simple, fast and user-friendly tool meant to simply perform faster compared to find. It is not meant to completely replace find, but rather give you an easy to use alternative that performs slightly faster.

Some of the notable features of fd:

  1. Easy to use syntax – fd *pattern* instead of find -iname *pattern*.
  2. Colorful output similar to the one of ls command.
  3. Fast performance. Developer’s benchmarks are available here.
  4. Smart search with case-insensitive by default and switches to case sensitive if patter containers an uppercase symbol.
  5. Does not look in hidden files and directories by default.
  6. Does not look into .gitignore by default.
  7. Unicode awareness.

How to Install fd in Linux

We are going to look at how to install fd in different Linux distributios.

For Ubuntu and Debian based distros, you will need to download the latest fd version from the release page and install it using following commands.

$ wget https://github.com/sharkdp/fd/releases/download/v7.3.0/fd-musl_7.3.0_amd64.deb
$ sudo dpkg -i fd-musl_7.3.0_amd64.deb

On Other Linux distributions, you can install fd from the default repository using package manager as shown.

# dnf install fd-find  [On Fedora]
# pacman -S fd         [On Arch Linux]
# emerge -av fd        [On Gentoo]
# zypper in fd         [On OpenSuse]

How to Use fd in Linux

Similar to find command, fd has many uses cases, but let’s start at checking the available options:

# fd -h
OR
# fd --help
fd Command Usage

fd Command Usage

Let’s have a look at few examples. You can run fd without any arguments, the output is very similar to ls -R command.

# fd

In the next fd examples, I will use a default WordPress installation located in /var/www/html/ to search for different files and folders.

In the example below, I have taken only the first 10 results for shorter output of the command.

# fd | head
fd Command Example

fd Command Example

Let’s say we want to find all jpg files. We can use the “-e” flag to filter by file extension:

# fd -e jpg
fd - Find JPG Files

fd – Find JPG Files

The “-e” flag can be used in combination with a pattern like this:

# fd -e php index

The above command will look for files with extension php and have the string “index” in them:

fd - Find String in Files

fd – Find String in Files

If you want to exclude some results, you can use the “-E” flag like this:

# fd -e php index -E wp-content

This command will look for all files with php extension, containing the string “index” and will exclude results from the “wp-content” directory.

fd - Exclude Files While Searching String in Files

fd – Exclude Files While Searching String in Files

If you want to specify a search directory, you simply need to give it as argument:

# fd <pattery> <directory>
fd - Find Files in Directory

fd – Find Files in Directory

Just as find, you can use -x or --exec arguments to perform parallel command execution with the search results.

Here is an example where we will use chmod to change permissions of the image files

# fd -e jpg -x chmod 644 {}

The above will find all files with extension jpg and will run chmod 644 <path-to-file>.

Here is some useful explanation and usage of the brackets:

  • {} – A placeholder which will be changed with the path of the search result (wp-content/uploads/01.jpg).
  • {.} – similar to {}, but without using the file extension (wp-content/uploads/01).
  • {/}: A placeholder that will be replaced by the basename of the search result (01.jpg).
  • {//}: Parent directory of the discovered path (wp-content/uploads).
  • {/.}: Only the basename, without the extension (01).
Conclusion

This was a brief review of the fd command, that some users may find easier to use and faster. As mentioned earlier in this article fd is not meant to completely replace find, but rather provide a simple usage, easier search and better performance. Fd does not take much space and is a nice tool to have in your arsenal.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Marin Todorov

I am a bachelor in computer science and a Linux Foundation Certified System Administrator. Currently working as a Senior Technical support in the hosting industry. In my free time I like testing new software and inline skating.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

3 Responses

  1. Andy Pahne says:

    Starting with Ubuntu 19.04, the package ‘fd-find‘ can be installed the usual way. There is no need to download and install the deb file manually.

  2. Marin Todorov says:

    Hi,

    Link to developer’s benchmark results were provided in the article, you probably missed it. I am including the link once more:

    https://github.com/sharkdp/fd#benchmark

  3. Z says:

    Can you back up the claims that it’s faster than the original ‘find’?

    If not – this is just a bunch of code and another out of district piece of software to maintain yourself.

    Looks like it was written so that the author doesn’t need to learn ‘find’ options and/or brag about a nearly useless piece of software.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.