recsel
Query and filter GNU recutils database records
TLDR
Select all records from a recfile
SYNOPSIS
recsel [options] [-e expression] [-t type] [file...]
DESCRIPTION
recsel is part of GNU Recutils, a set of tools for managing plain-text databases using the rec format. It selects and prints records from recfiles based on expressions and criteria.
Recfiles are human-readable text files where each record is a collection of named fields separated by blank lines. The format is simple, versionable with git, and editable with any text editor.
Selection expressions support comparison operators (=, !=, <, >, <=, >=), logical operators (&&, ||, !), pattern matching (~), and field existence checks. Expressions operate on field values within each record.
Output can be restricted to specific fields with -p, sorted with -S, and limited with -n. The tool handles multiple record types within a single file using -t.
PARAMETERS
-e expression
Select records matching the expression-t type
Select records of specified type only-p fields
Print only specified fields (comma-separated)-P fields
Print specified fields without record separators-c, --count
Print count of matching records-C, --collapse
Collapse multiple field values into one-S field
Sort records by specified field-G field
Group records by specified field-n max
Return at most max records-R random
Return random records-d, --print-descriptors
Print record descriptors
EXPRESSION SYNTAX
field = "value": Exact string match
field ~ "pattern": Regular expression match
field < number: Numeric comparison
field && field2: Logical AND
#field: Field exists
!#field: Field does not exist
CAVEATS
Field names and string values in expressions must follow recutils quoting rules. Strings with spaces require quotes.
Numeric comparisons require fields to contain valid numbers. Non-numeric values cause comparison failures.
Large recfiles may be slow to process compared to proper databases, but the simplicity and portability often outweigh performance concerns for moderate data sizes.
