How To Install And Use fd Command In Linux

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…

Qadry
unixcop Admin

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

You might also likeRELATED

How to set PassivePortRange and PassiveIP in pure-ftpd on Ubuntu to secure the app!

Introduction Hi guys, We will talk about setting PassivePortRange and PassiveIP in pure-ftpd. If you run a firewall on your Linux server and want to...

Install Java 8 on CentOS 8

Hi Guys, In this guide, we’ll show you how to install Oracle’s Java 8 programming language on CentOS 8 . It's an object-oriented language...

How to install flameshot on RHEL/CentOS using Snapcraft

In this post, you will learn how to install Flameshot on RHEL / CentOS Flameshot is a powerful open source screenshot and annotation tool for...