How To Install And Use fd Command In Linux

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Introduction

Hi guys, there is an alternative command for find command – fd â€“ which has some additional features, including friendlier colorized output, faster search speed, and some useful defaults.

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.

In this tutorial, we’ll show you how to install and use fd command.

Install fd in Linux

  • Ubuntu, Debian based distros, 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/v8.3.1/fd-musl_8.3.1_amd64.deb
sudo dpkg -i fd-musl_8.3.1_amd64.deb
  • On Other Linux distributions:
dnf install fd-find     #On Fedora
zypper in fd            #On OpenSuse
pacman -S fd            #On Arch Linux

Use fd in Linux

  • Run fd with no argument, the output is similar to ls -R command as follows:
fd
  • Take only the first 10 output for shorter output of the command at the first example.
  • Take only the latest 10 output for shorter output of the command at the second example.
fd | head
fd | tail
  • Use the -e flag to filter the output by file extension such as .png or .txt … etc as shown below
fd -e png
fd -e txt
  • Yo can use a combination of extensions with -e flag as shown
fd -e php  index /var/www/html/

The command will look for the files with extension php and have the string index as shown below in the output.

  • You can use the -E flag to exclude the results you want (for example below, I want to exclude the files with migration string, So it will lookup for files containing the string index and will exclude results from the migration directory.
fd -e php index -E migration /var/www/html/

If you want to make sure from the result below, kindly go back to the previous screenshot, you will find migration directory that we exclude it here.

  • If you want to specify a search directory, you simply need to give it as argument
fd [pattern] [directory]
  • You can use -x or –exec arguments to perform parallel command execution with the search results.

For example:

fd -e index -x chmod 755 {}

The above command will find all files with extension index and will run chmod 755 [path to file]

  • To check options of fd command, or get the help page, run:
fd -h
OR
fd --help

Conclusion

That’s it

We illustrated how to install and use fd command {the find command alternative} with its some of important opetions.

thanks…

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
MQ-Jr
MQ-Jr
unixcop Admin

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook