GNU recutils is a set of tools and libraries to access human-editable, text-based databases called recfiles.
GNU recutils
is a set of tools and libraries to access human-editable, text-based databases called recfiles
. The data is stored as a sequence of records, each record containing an arbitrary number of named fields. Recfiles are human-readable, human-writable and still easy to parse and to manipulate automatically.
recfile
Format1. Fields : The key–value pairs which comprise the data.
Name: hamzeh
[a-zA-Z%][a-zA-Z0-9_]*
)2. Records : The main entities of a recfile.
Name: hamzeh
Phone: 00989111111111
Email: h.nasajpour@pantherx.org
3. Comments : Information for humans’ benefit only.
4. Record Description : Describing different types of records. Certain properties of a set of records can be specified by preceding them with a record descriptor. A record descriptor is itself a record, and uses fields with some predefined names to store properties.
%rec
: The most basic property that can be specified for a set of records is their type. The special field name %rec is used for that purpose:%type
%doc
As well as a name, it is a good idea to provide a description of the record set. This is sometimes called the record set’s documentation and is specified using the %doc field.recfile
Sample (contacts.rec
):Name
and Phone
field are mandatory and they can’t be empty.Email
field is optional.# -*- mode: rec -*-
%rec: Contact
%mandatory: Name Phone
Name: hamzeh
Phone: 00989111111111
Phone: 00989123456789
Email: h.nasajpour@pantherx.org
Name: hadi
Phone: 00989222222222
# End of contacts.rec
recutils
Commands1. recinf
- reads the given rec files (or the data from standard input if no file is specified) and prints a summary of the record types contained in the input.
$ recinf contacts.rec
2 Contact
2. recfix
- check a recfile for errors:
$ recfix contacts.rec
3. recsel
- recsel reads the given rec files (or the data in the standard input if no file is specified) and prints out records (or part of records) based upon some criteria specified by the user.
$ recsel contacts.rec
Name: hamzeh
Phone: 00989111111111
Phone: 00989123456789
Email: h.nasajpour@pantherx.org
Name: hadi
Phone: 00989222222222
$ recsel -e "Name = 'hamzeh'" -P Phone contacts.rec
00989111111111
00989123456789
$ recsel -e "Name = 'hamzeh'" -P Email,Phone contacts.rec
h.nasajpour@pantherx.org
00989111111111
00989123456789
4. recins
- adds new records to a rec file or to rec data read from standard input.
$ recins -f Name -v Alex -f Phone -v 9898111222333 contacts.rec
$ recsel contacts.rec
Name: Alex
Phone: 9898111222333
Name: hamzeh
Phone: 00989111111111
Phone: 00989123456789
Email: h.nasajpour@pantherx.org
Name: hadi
Phone: 00989222222222
https://www.gnu.org/software/recutils/manual/
PantherX & (unofficial) GNU Guix Wiki.
Last update: 2024-04-21 10:28:03 +0000 | Apache-2.0
Inspired by the excellent Arch Linux Wiki