fselect
Find files with SQL-like queries
TLDR
Select full path and size from temporary or configuration files in a given directory
Find square images
Find old-school rap 320kbps MP3 files
Select only the first 5 results and output as JSON
Use SQL aggregate functions to calculate minimum, maximum and average size of files in a directory
SYNOPSIS
fselect [OPTIONS] [QUERY]
PARAMETERS
-t <type>, --type <type>
Filters results by file type. Common types include f (file), d (directory), l (symlink), s (socket), p (fifo), b (block device), c (char device).
-x, --exclude-dir
Excludes directories from the search results, returning only files that match the criteria.
-p, --print0
Prints results separated by a null character, useful for piping output to other commands like xargs -0.
-i, --ignore-case
Performs case-insensitive matching for string comparisons within the query conditions.
-s <char>, --separator <char>
Specifies the column separator character for table-formatted output.
-S, --no-headers
Suppresses the printing of the header row in table-formatted output.
-c <mode>, --color <mode>
Controls colored output. Modes can be auto, always, or never.
-d <path>, --database <path>
Specifies an alternative path to the database file for potentially cached searches.
-o <format>, --output <format>
Sets the output format. Supported formats include table (default), json, tsv, csv, and lines.
-j, --json
A shortcut for --output json, outputting results in JSON format.
-n, --dry-run
Parses the query and shows what it would do without actually performing the search.
-h, --help
Displays the help message with command options and examples.
-v, --version
Prints the version information of fselect.
DESCRIPTION
fselect is a powerful command-line tool that enables users to search for files and directories using an intuitive, SQL-like query language. It provides a modern alternative to traditional file search utilities like find, allowing for more expressive and readable search criteria.
Users can construct queries to filter results based on various attributes such as file name, path, size, modification date, permissions, owner, and type. It supports advanced features like regular expressions, case-insensitive matching, sorting (ORDER BY), and limiting results (LIMIT).
Written in Rust, fselect is designed for high performance and efficiency, making complex file system searches faster and more manageable. It supports diverse output formats, including plain text, CSV, TSV, and JSON, facilitating seamless integration into scripts and workflows.
CAVEATS
While powerful and intuitive, fselect is not typically pre-installed on all Linux distributions like find. Its SQL-like query language, while beneficial for those familiar with SQL, may present a slight learning curve for users accustomed to traditional command-line syntax.
QUERY LANGUAGE
The core strength of fselect lies in its SQL-like query syntax. Users can specify which columns to SELECT (e.g., name, path, size, date, perm, owner, group, inode, type), the starting directory with FROM (e.g., . for current directory, / for root), and filtering conditions using WHERE (e.g., size > 1m, name ~ ".*\.txt", date > "2023-01-01"). Results can be sorted with ORDER BY and limited in quantity using LIMIT.
PERFORMANCE CONSIDERATIONS
Implemented in Rust, fselect is optimized for speed and efficiency. It often processes complex search queries faster than traditional tools by leveraging Rust's concurrency features and optimized data structures. This makes it particularly effective for large file systems or intricate search criteria.
HISTORY
fselect was created by junegunn (Jun G. Lee) and first released around 2018. It rapidly gained traction as a modern, user-friendly alternative to more complex file search utilities, leveraging the performance benefits of Rust. Its development has focused on providing a more expressive and accessible query interface for file system navigation.