Install fd Command for Finding Files on Ubuntu 20.04

Install fd Command for Finding Files on Ubuntu 20.04

The fd is a command line tool that allows to find files in a directory hierarchy. This tool can be used as an alternative to the find command.

This tutorial demonstrates how to install fd command on Ubuntu 20.04.

Install fd

Get the latest version tag of fd release from GitHub and assign it to variable:

FD_VERSION=$(curl -s "https://api.github.com/repos/sharkdp/fd/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')

Download Debian package (.deb) from releases page of the fd repository:

curl -Lo fd.deb "https://github.com/sharkdp/fd/releases/latest/download/fd_${FD_VERSION}_amd64.deb"

Install fd:

sudo apt install -y ./fd.deb

When installation is finished, we can check fd version:

fd --version

Remove .deb package because no longer needed it:

rm -rf fd.deb

Testing fd

The fd command has many uses cases. For example, the following command searches for files and directories in the specified directory:

fd hosts /etc

An example of output:

/etc/cloud/templates/hosts.alpine.tmpl
/etc/cloud/templates/hosts.debian.tmpl
/etc/cloud/templates/hosts.freebsd.tmpl
/etc/cloud/templates/hosts.photon.tmpl
/etc/cloud/templates/hosts.redhat.tmpl
/etc/cloud/templates/hosts.suse.tmpl
/etc/hosts
/etc/hosts.allow
/etc/hosts.deny

Uninstall fd

If you decided to completely remove fd, run the following command:

sudo apt purge --autoremove -y fd

Leave a Comment

Cancel reply

Your email address will not be published.