Install fzf on Ubuntu 24.04

Install fzf on Ubuntu 24.04

The fzf (short for fuzzy finder) is a command line tool used to search and filter files, command history, processes, hostnames, bookmarks, git commits, and more, all interactively. It performs a fuzzy search, meaning it doesn't require exact matching of characters. You can type part of a string, and fzf will still find relevant results based on their similarity to your input. This tutorial shows how to install fzf on Ubuntu 24.04.

Install fzf

Check the current fzf version from its GitHub repository and assign it to a variable:

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

Using previously determined version, download tar.gz. file:

wget -qO fzf.tar.gz https://github.com/junegunn/fzf/releases/latest/download/fzf-$FZF_VERSION-linux_amd64.tar.gz

Extract executable to /usr/local/bin directory:

sudo tar xf fzf.tar.gz -C /usr/local/bin

We can check fzf version as follows:

fzf --version

Remove unnecessary tar.gz file:

rm -rf fzf.tar.gz

Testing fzf

To use fzf, you typically pipe the output of another command into it, allowing you to interactively search and select from the results. For example:

sudo find /var/log -type f | fzf

The command searches for all files under the /var/log directory with find, and then pipes the list of files into fzf. The fzf will display the files in an interactive list where you can type to narrow down your options and select a file.

File selection using fzf on Ubuntu

Once you've made your selection, fzf will output the chosen file's path, which can be used in subsequent commands. Output example:

/var/log/apt/history.log

Uninstall fzf

To uninstall fzf, delete the associated file:

sudo rm -rf /usr/local/bin/fzf

Leave a Comment

Cancel reply

Your email address will not be published.