Install fselect on Ubuntu 24.04

Install fselect on Ubuntu 24.04

The fselect is a command line tool that allows users to perform SQL-like queries on the file system. It enables users to search for files based on various criteria, such as name, size, modification date, and other file attributes, using a syntax similar to SQL. This tool is particularly useful for users who are comfortable with SQL and want to leverage that familiarity to query their file system efficiently. This tutorial explains how to install fselect on Ubuntu 24.04.

Install fselect

Download latest version of fselect from GitHub:

sudo wget -qO /usr/local/bin/fselect.gz https://github.com/jhspetersson/fselect/releases/latest/download/fselect-x86_64-linux-musl.gz

Run the following command to extract the binary file out of the archive:

sudo gunzip /usr/local/bin/fselect.gz

Set execute permission for file:

sudo chmod a+x /usr/local/bin/fselect

We can verify fselect version as follows:

fselect --version

Testing fselect

To use the fselect command, specify the attributes you want to retrieve, the directory to search in, and the conditions for filtering files. For example, the following command searches the /var/log directory for files with names ending in .log and outputs their paths:

sudo fselect path from /var/log where name = '*.log'

Output example:

/var/log/vmware-network.log
/var/log/php8.2-fpm.log
/var/log/bootstrap.log
/var/log/vmware-network.5.log
/var/log/vmware-network.7.log
/var/log/ubuntu-advantage.log
/var/log/fontconfig.log
/var/log/gpu-manager.log
/var/log/boot.log
...

Uninstall fselect

If fselect is no longer needed, remove related file:

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

Leave a Comment

Cancel reply

Your email address will not be published.