### recsel -p example Source: https://www.gnu.org/software/recutils/manual/html_node/Invoking-recsel.html Example of using the -p option to print specific fields (Name and Email) for each matching record. ```text -p Name,Email ``` -------------------------------- ### Example recfile stock.rec Source: https://www.gnu.org/software/recutils/manual/html_node/Deleting-Records.html A sample recfile with three records, each having Title and Expiry fields. Used as the input for the recdel example. ```recfile %rec: Item %type: Expiry date %sort: Title Title: First Aid Kit Expiry: 2 May 2009 Title: Emergency Rations Expiry: 10 August 2009 Title: Life raft Expiry: 2 March 2009 ``` -------------------------------- ### recset number option example Source: https://www.gnu.org/software/recutils/manual/html_node/Invoking-recset.html Example of using the -n option to specify record positions. ```bash -n 0,2,4-9 ``` -------------------------------- ### Exact size constraint example Source: https://www.gnu.org/software/recutils/manual/html_node/Size-Constraints.html Example of a record descriptor using %size to require exactly 7 records of type Day. ```rec %rec: Day %size: 7 %type: Name enum + Monday Tuesday Wednesday Thursday Friday + Saturday Sunday %doc: There should be exactly 7 days. ``` -------------------------------- ### Relational size constraint example Source: https://www.gnu.org/software/recutils/manual/html_node/Size-Constraints.html Example using the <= operator to limit the number of Item records to at most 100. ```rec %rec: Item %key: Id %size: <= 100 %doc: We have at most 100 different articles. ``` -------------------------------- ### Example recfile with multiple record types Source: https://www.gnu.org/software/recutils/manual/html_node/Selecting-by-Type.html A sample recfile named gnu.rec containing two record types: Maintainer and Package. This file is used in the subsequent recsel examples. ```rec %rec: Maintainer Name: Jose E. Marchesi Email: jemarch@gnu.org Name: Luca Saiu Email: positron@gnu.org %rec: Package Name: GNU recutils LastRelease: 12 February 2014 Name: GNU epsilon LastRelease: 10 March 2013 ``` -------------------------------- ### Example database marks.rec Source: https://www.gnu.org/software/recutils/manual/html_node/Adding-Anonymous-Records.html A sample recfile containing records of type Marks. ```text %rec: Marks %type: Class enum A B C Name: Alfred Class: A Name: Bertram Class: B ``` -------------------------------- ### Enforce date order with %constraint Source: https://www.gnu.org/software/recutils/manual/html_node/Arbitrary-Constraints.html Example of a Task record type where the Start date must occur before the End date. ```recutils %rec: Task %type: Start,End date %constraint: Start << End ``` -------------------------------- ### Example recfile with Date of Birth Source: https://www.gnu.org/software/recutils/manual/html_node/Selecting-by-predicate.html A sample recfile structure using a date type for the Dob field. ```text # Date of Birth %type: Dob date Name: Alfred Nebel Dob: 20 April 2010 Email: alf@example.com Name: Bertram Worcester Dob: 3 January 1966 Email: bert@example.com Name: Charles Spencer Dob: 4 July 1997 Email: charlie@example.com Name: Dirk Hogart Dob: 29 June 1945 Email: dirk@example.com Name: Ernest Wright Dob: 26 April 1978 Email: ernie@example.com ``` -------------------------------- ### Using comments for headers and markers Source: https://www.gnu.org/software/recutils/manual/html_node/Comments.html Example demonstrating the use of comments for file headers, TODO lists, and section markers. ```rec # -*- mode: rec -*- # # TODO # # This file contains the Bugs database of GNU recutils. # # Blah blah... ... # End of TODO ``` -------------------------------- ### Example record with multiple Email fields Source: https://www.gnu.org/software/recutils/manual/html_node/Field-Expressions.html A sample record used to demonstrate field selection with subscripts. ```text Name: Mr. Foo Email: foo@foo.com Email: foo@foo.org Email: mr.foo@foo.org ``` -------------------------------- ### Example of a malformed recfile Source: https://www.gnu.org/software/recutils/manual/html_node/Syntactical-Errors.html A recfile example containing a syntactical error where the colon is missing after the field name. ```text %rec: Article %key Id Name: Thing Id: 0 ``` -------------------------------- ### Using pipes to include record descriptors Source: https://www.gnu.org/software/recutils/manual/html_node/Remote-Descriptors.html A command-line example showing how to combine a descriptor file and a data file using pipes. ```bash $ cat descriptor.rec data.rec | recsel ... ``` -------------------------------- ### Get help for readrec built-in Source: https://www.gnu.org/software/recutils/manual/html_node/Bash-Builtins.html Use the bash help command to display help for the readrec built-in. ```bash $ help readrec ``` -------------------------------- ### Example Item record without auto-generated fields Source: https://www.gnu.org/software/recutils/manual/html_node/Auto_002dGenerated-Fields.html A sample recfile record structure using Description as the key. ```rec %rec: Item %key: Description Description: 2cm metal soldier WWII Amount: 2111 Description: Flying Helicopter Indoor Maxi Amount: 8 ... ``` -------------------------------- ### %mandatory example with address book Source: https://www.gnu.org/software/recutils/manual/html_node/Mandatory-Fields.html Example of using %mandatory to require a Name field in every Contact record. The records shown include Name and other optional fields. ```rec %rec: Contact %mandatory: Name Name: Granny Phone: +12 23456677 Name: Yoyodyne Corp. Email: sales@yoyod.com Phone: +98 43434433 ``` -------------------------------- ### Record with multiple Email fields for alias example Source: https://www.gnu.org/software/recutils/manual/html_node/Field-Expressions.html Sample record used to demonstrate aliases with different positions. ```text Name: Mr. Foo Email: primary@email.com Email: secondary@email.com Email: other@email.com ``` -------------------------------- ### String Literals Source: https://www.gnu.org/software/recutils/manual/html_node/SEX-Operands.html Examples of string literals delimited by single or double quotes. ```text 'Hello.' 'The following example is the empty string.' '' ``` -------------------------------- ### recinf default output Source: https://www.gnu.org/software/recutils/manual/html_node/Invoking-recinf.html Example output showing the record type name and count for multiple input files. ```bash $ recinf hackers.rec tasks.rec 25 Hacker 102 Task ``` -------------------------------- ### Commenting out registers and fields Source: https://www.gnu.org/software/recutils/manual/html_node/Comments.html Example showing how to comment out specific fields or data within a recfile record. ```rec Name: Jose E. Marchesi # Occupation: Software Engineer # Severe lack of brain capacity # Fired on 02/01/2009 (without compensation) Occupation: Unoccupied ``` -------------------------------- ### Event database with integer IDs Source: https://www.gnu.org/software/recutils/manual/html_node/Unique-Identifiers.html Example of an Event database using simple integer-based auto-generated IDs. ```rec %rec: Event %key: Id %mandatory: Title Date Id: 0 Title: Team meeting Date: 12-08-2013 Id: 1 Title: Dave's birthday Date: 20-12-2013 ``` -------------------------------- ### Account database record structure Source: https://www.gnu.org/software/recutils/manual/html_node/Decrypting-Data.html Example of a recutils database file with a confidential Password field. ```rec %rec: Account %key: Login %confidential: Password Login: foo Name: Mr. Foo Email: foo@foo.com Password: encrypted-AAABBBCCCDDD Login: bar Name: Ms. Bar Email: bar@bar.org Password: encrypted-XXXYYYZZZUUU ``` -------------------------------- ### Defining Record Sets with %rec and %doc Fields Source: https://www.gnu.org/software/recutils/manual/html_node/Documenting-Records.html Example showing two record sets, 'Contact' and 'Associate', each defined with a %rec name and a descriptive %doc field. ```rec %rec: Contact %doc: Family, friends and acquaintances (other than business). Name: Granny Phone: +12 23456677 Name: Edwina Phone: +55 0923 8765 %rec: Associate %doc: Colleagues and other business contacts Name: Karl Schmidt Phone: +49 88234566 Name: Genevieve Curie Phone: +33 34 87 65 ``` -------------------------------- ### date command examples for relative month calculation Source: https://www.gnu.org/software/recutils/manual/html_node/Relative-items-in-date-strings.html Shows how 'date -R' and 'date --date' handle relative month calculations. The example '2020-07-31 -1 month' may evaluate to July 1 due to invalid June 31, so using the 15th of the month gives the correct previous month. ```shell $ date -R Thu, 31 Jul 2020 13:02:39 -0400 $ date --date='-1 month' +'Last month was %B?' Last month was July? $ date --date="$(date +%Y-%m-15) -1 month" +'Last month was %B!' Last month was June! ``` -------------------------------- ### Sample contacts database Source: https://www.gnu.org/software/recutils/manual/html_node/readrec.html A simple recutils database with contacts, including multiple Email fields and a Checked field. Used as input for the readrec example. ```rec Name: Mr. Foo Email: foo@bar.com Email: bar@baz.net Checked: no Name: Mr. Bar Email: bar@foo.com Telephone: 999666000 Checked: yes ``` -------------------------------- ### Example org-mode results table Source: https://www.gnu.org/software/recutils/manual/html_node/Using-ob_002drec_002eel.html The output produced by the org-mode source block, displayed as an org table. ```org #+RESULTS: | Title | Author | Date | Location | |---------------------+-----------------+-----------------+----------| | The Colour of Magic | Terry Pratchett | 4/20/01 11:15pm | loaned | ``` -------------------------------- ### Field Name References Source: https://www.gnu.org/software/recutils/manual/html_node/SEX-Operands.html Examples of using field names as operands in selection expressions. ```text Name Email long_field_name ``` -------------------------------- ### Define real fields with examples Source: https://www.gnu.org/software/recutils/manual/html_node/Scalar-Field-Types.html Defines a record with real fields Width and Height, showing valid real values including an integer-like value. ```rec %rec: Rectangle %typedef: Longitude_t real %type: Width Longitude_t %type: Height Longitude_t Width: 25.01 Height: 10 ``` -------------------------------- ### Example Item record with manual Id field Source: https://www.gnu.org/software/recutils/manual/html_node/Auto_002dGenerated-Fields.html A sample recfile record structure using a manual numeric Id as the primary key. ```rec %rec: Item %key: Id %mandatory: Description Id: 0 Description: 2cm metal soldier WWII Amount: 2111 Id: 1 Description: Flying Helicopter Indoor Maxi Amount: 8 ... ``` -------------------------------- ### Numeric Literals Source: https://www.gnu.org/software/recutils/manual/html_node/SEX-Operands.html Examples of integer and real number literals, including negative values and different base representations. ```text 10000 0 0xFF -0xa 012 -07 -1342 .12 -3.14 ``` -------------------------------- ### Example database with %rec, %type, and %mandatory fields Source: https://www.gnu.org/software/recutils/manual/html_node/Record-Sets-Properties.html Shows a recutils database where the record descriptor specifies an optional numeric 'Id' field via %type and a mandatory 'Title' field via %mandatory. The %rec field names the record type 'Item'. Note that special fields always start with '%'. ```rec %rec: Item %type: Id int %mandatory: Title Id: 10 Title: Notebook (big) Id: 11 Title: Fountain Pen ``` -------------------------------- ### Sample Shop Inventory Database Source: https://www.gnu.org/software/recutils/manual/html_node/Grouping-Records.html A sample recfile containing shop inventory items with fields for Type, Category, Price, LastSell, and Available. ```text Type: EC Car Category: Toy Price: 12.2 LastSell: 20-April-2012 Available: 623 Type: Terria Category: Food Price: 0.60 LastSell: 22-April-2012 Available: 8239 Type: Typex Category: Office Price: 1.20 LastSell: 22-April-2012 Available: 10878 Type: Notebook Category: Office Price: 1.00 LastSell: 21-April-2012 Available: 77455 Type: Sexy Puzzle Category: Toy Price: 6.20 LastSell: 6.20 Available: 12 ``` -------------------------------- ### Add the first record to a database with recins Source: https://www.gnu.org/software/recutils/manual/html_node/Adding-Records-With-recins.html Demonstrates adding a record with Name and Email fields to an empty contacts.rec file using -f and -v flags. ```bash $ recins -f Name -v "Mr Foo" -f Email -v foo@bar.baz contacts.rec $ cat contacts.rec Name: Mr. Foo Email: foo@bar.baz ``` -------------------------------- ### Invalid inline comment example Source: https://www.gnu.org/software/recutils/manual/html_node/Comments.html Example showing that the '#' character does not initiate a comment when placed in the middle of a line. ```rec Name: Peter the Great # Russian Tsar Age: 53 ``` -------------------------------- ### Examples of regexp field values Source: https://www.gnu.org/software/recutils/manual/html_node/String-Field-Types.html Shows valid and invalid values for a field of type `Id_t`. The first example matches the pattern; the second does not. ```rec IDCard: 123456789Z IDCard: invalid id card ``` -------------------------------- ### Examples of line field values Source: https://www.gnu.org/software/recutils/manual/html_node/String-Field-Types.html Shows valid and invalid values for a field of type `line`. The third example is invalid because it contains a newline. ```rec Name: Mr. Foo Bar Name: Mrs. Bar Baz Name: This is + invalid ``` -------------------------------- ### Relative date item examples Source: https://www.gnu.org/software/recutils/manual/html_node/Relative-items-in-date-strings.html Examples of relative date items that adjust the current date forward or backward. Effects accumulate, and units include year, month, day, etc. ```text 1 year 1 year ago 3 years 2 days ``` -------------------------------- ### Boolean field literals Source: https://www.gnu.org/software/recutils/manual/html_node/Enumerated-Field-Types.html Examples of valid literals for boolean fields. ```recutils SwitchedOn: 1 SwitchedOn: yes SwitchedOn: false ``` -------------------------------- ### Alias example Source: https://www.gnu.org/software/recutils/manual/html_node/Field-Expressions.html Field expression that renames the Email field to ElectronicMail. ```text Name,Email:ElectronicMail ``` -------------------------------- ### recdel synopsis Source: https://www.gnu.org/software/recutils/manual/html_node/Invoking-recdel.html Shows the command-line syntax for recdel, including options for type, indexes, expression, quick, and random. If no file is given, recdel acts as a filter reading from standard input and writing to standard output. ```bash recdel [OPTIONS]... [-t type] \ [-n indexes | -e record_expr | -q str | -m num] \ [file] ``` -------------------------------- ### Escaped String Literals Source: https://www.gnu.org/software/recutils/manual/html_node/SEX-Operands.html Examples of strings containing escaped delimiter characters. ```text 'This string contains an apostrophe: \'.' "This one a double quote: \" ." ``` -------------------------------- ### Example of type aliasing Source: https://www.gnu.org/software/recutils/manual/html_node/Declaring-Types.html Defining multiple types as aliases for an integer type. ```text %typedef: Id_t int %typedef: Item_t Id_t %typedef: Transaction_t Id_t ``` -------------------------------- ### Record descriptor with %sort and sample data Source: https://www.gnu.org/software/recutils/manual/html_node/Sorted-Output.html Example of a record descriptor using %sort to order inventory records by date. The database is not physically ordered; unsorted record sets are not a data integrity problem. ```recfile %rec: Item %type: Date date %sort: Date Id: 1 Title: Staplers Date: 10 February 2011 Id: 2 Title: Ruler Pack 20 Date: 2 March 2009 ... ``` -------------------------------- ### List all tables including system tables Source: https://www.gnu.org/software/recutils/manual/html_node/Importing-MDB-Files.html Use the -s and -l options to include system tables (prefixed with MSys) in the listing. ```bash $ mdb2rec -s -l sales.mdb MSysObjects MSysACEs MSysQueries MSysRelationships Customers Products Orders ``` -------------------------------- ### Select multiple fields with combined predicates Source: https://www.gnu.org/software/recutils/manual/html_node/Selecting-by-predicate.html Demonstrates using multiple -e arguments with logical AND (&&) and selecting multiple fields with -p. ```bash $ recfix acquaintances.rec $ recsel -e "Dob >> '31 July 1994' && Dob << '01 August 1998'" \ -p Name,Email acquaintances.rec Name: Charles Spencer Email: charlie@example.com ``` -------------------------------- ### Define enumerated types Source: https://www.gnu.org/software/recutils/manual/html_node/Enumerated-Field-Types.html Examples of defining enumerated types using the %typedef directive. ```recutils %typedef: Status_t enum NEW STARTED DONE CLOSED %typedef: Day_t enum Monday Tuesday Wednesday Thursday Friday + Saturday Sunday ``` -------------------------------- ### Invalid circular type definition Source: https://www.gnu.org/software/recutils/manual/html_node/Declaring-Types.html An example of an invalid set of declarations that creates a loop. ```text %typedef: A_t B_t %typedef: B_t C_t %typedef: C_t A_t ``` -------------------------------- ### recinf synopsis Source: https://www.gnu.org/software/recutils/manual/html_node/Invoking-recinf.html The basic command structure for invoking recinf. ```bash recinf [option]... [file]... ``` -------------------------------- ### Example of a record descriptor Source: https://www.gnu.org/software/recutils/manual/html_node/Remote-Descriptors.html A record set containing transactions with the type Transaction defined in the descriptor. ```text %rec: Transaction Id: 10 Title: House rent Id: 11 Title: Loan ``` -------------------------------- ### Grouping by Category with recsel Source: https://www.gnu.org/software/recutils/manual/html_node/Grouping-Records.html Example of using the -G argument to group records by the Category field. ```bash $ recsel -G Category Type: Terria Category: Food Price: 0.60 LastSell: 22-April-2012 Available: 8239 Type: Typex Category: Office Price: 1.20 LastSell: 22-April-2012 Available: 10878 Type: Notebook Price: 1.00 LastSell: 21-April-2012 Available: 77455 Type: EC Car Category: Toy Price: 12.2 LastSell: 20-April-2012 Available: 623 Type: Sexy Puzzle Price: 6.20 LastSell: 6.20 Available: 12 ``` -------------------------------- ### recfmt synopsis Source: https://www.gnu.org/software/recutils/manual/html_node/Invoking-recfmt.html The basic command-line syntax for invoking the recfmt utility. ```bash recfmt [option]... [template] ``` -------------------------------- ### Add a second record to a database with recins Source: https://www.gnu.org/software/recutils/manual/html_node/Adding-Records-With-recins.html Shows how subsequent invocations of recins append new records to the existing database file. ```bash $ recins -f Name -v "Mr Bar" -f Email -v bar@gnu.org contacts.rec $ cat contacts.rec Name: Mr. Foo Email: foo@bar.baz name: Mr. Bar Email: bar@gnu.org ``` -------------------------------- ### Define enumerated types with comments Source: https://www.gnu.org/software/recutils/manual/html_node/Enumerated-Field-Types.html Example of defining an enumerated type with comments delimited by parentheses. ```recutils %typedef: TaskStatus_t enum + NEW (The task was just created) + IN_PROGRESS (Task started) + CLOSED (Task closed) ``` -------------------------------- ### Detailed aggregate with grouping Source: https://www.gnu.org/software/recutils/manual/html_node/Aggregate-Functions.html Display individual prices alongside the category average using grouping. ```bash $ recsel -p "Category,Price,Avg(Price)" -G Category items.rec Category: Food Price: 0.60 Avg_Price: 0.600000 Category: Office Price: 1.20 Price: 1.00 Avg_Price: 1.100000 Category: Toy Price: 12.2 Price: 6.20 Avg_Price: 9.200000 ``` -------------------------------- ### recset synopsis Source: https://www.gnu.org/software/recutils/manual/html_node/Invoking-recset.html The basic command structure for invoking recset. ```bash recset [option]... [file]... ``` -------------------------------- ### recfix synopsis Source: https://www.gnu.org/software/recutils/manual/html_node/Invoking-recfix.html Shows the command-line synopsis for recfix. If no file is specified, recfix acts as a filter, reading from standard input and writing to standard output. ```text recfix [option]... [operation] [op_option]... [file] ```