Recfiles

{{Short description|Plain text database format}}

{{Infobox file format

| name = recfiles

| icon =

| logo =

| screenshot =

| caption = GNU Recutils

| extension = .rec

| mime =

|_nomimecode = yes

| type code =

| uniform type =

| owner =

| genre = Data interchange

| free = yes

| open = yes

| url = {{URL|https://www.gnu.org/software/recutils/}}

}}

recfiles is a file format for human-editable, plain text databases.{{cite web

|url=https://www.gnu.org/software/recutils/manual/Purpose.html

|work=GNU Recutils Manual

|title=Purpose

|access-date=2020-12-02

|date=2019-01-03

|first=Jose E

|last=Marchesi

}}{{cite web |url=https://labs.tomasino.org/gnu-recutils/ |title=GNU Recutils |author=James Tomasino |date=2020-01-26 |access-date=2020-02-09}}

{{Infobox software

| title = GNU Recutils

| name = GNU Recutils

| logo =

| logo caption =

| logo alt =

| logo size =

| collapsible =

| screenshot =

| screenshot size =

| screenshot alt =

| caption =

| other_names =

| author = Jose E. Marchesi

| developer =

| released = {{Start date and age|2010|12|03}}

| ver layout =

| discontinued =

| latest release version = 1.9

| latest release date = {{Start date and age|2022|04|16}}{{cite web |title=Index of /gnu/recutils |url=https://ftp.gnu.org/gnu/recutils/ |website=ftp.gnu.org |access-date=11 April 2023}}

| latest preview version =

| latest preview date =

| repo = {{URL|https://git.savannah.gnu.org/cgit/recutils.git}}

| qid =

| programming language = C

| middleware =

| engine =

| operating system =

| platform =

| included with =

| replaces =

| replaced_by =

| service_name =

| size =

| standard =

| language =

| language count =

| language footnote =

| genre =

| license = GNU General Public License

| website = {{URL|https://www.gnu.org/software/recutils/}}

}}

Databases using this file format can be edited using any text editor. Recfiles allow for basic relational database operations, such as typing, auto-incrementing, as well as a simple join operation.

Recutils is a collection of tools, like recfmt, recsel, and rec2csv used to work with recfile databases.{{Cite web|url=https://www.gnu.org/software/recutils/|title = GNU Recutils - GNU Project - Free Software Foundation}}

Various software libraries support the format.{{cite web |url=https://lists.gnu.org/archive/html/help-recutils/2019-04/msg00000.html |title=Relational pipes and GNU Recutils |author=František Kučera |date=2019-04-08}}{{Cite web|url=https://github.com/maninya/python-recutils/|title = Python-recutils|website = GitHub|date = 12 January 2022}}{{Cite web|url=https://github.com/aisamanra/rrecutils/|title=Aisamanra/Rrecutils|website=GitHub|date=13 January 2022}}

Syntax

Data are stored in text files with empty lines separating records. Fields within a record are lines starting with their name and a colon; it is possible to wrap long entries. Multiple record types can be maintained in a single text file.

Example

  1. This is a recfile document.

%rec: Text

%type: Year int

Author: Doug McIlroy

Year: 1964

Note: The Origin of Unix Pipes

Title: Unix Text Processing

Author: Dale Dougherty

Author: Tim O'Reilly

Year: 1987

Publisher: Hayden Books

Author: William Shakespeare

Title: Hamlet

Year: 1599

Year: 1600

Year: 1601

Utilities

Recutils from the GNU Project are a set of free command line utilities to process recfiles.{{cite web |title=GNU Recutils |url=https://www.gnu.org/software/recutils/manual/recutils.html |website=www.gnu.org |access-date=3 January 2025}}

These include:

  • recsel – search for and print fields from records matching a query
  • recins – insert a record, or replace existing records
  • recdel – delete a record, or delete a set of records
  • recfix – sort the records
  • recset – add or update individual fields

This example command would output the following three lines (of the two original entries, one having two authors):

$ recsel -e 'Year > "1900"' -p Author

Author: Doug McIlroy

Author: Dale Dougherty

Author: Tim O'Reilly

See also

{{Portal|Free and open-source software}}

References

{{reflist}}