Skip to content

Instantly share code, notes, and snippets.

@gmolveau
Last active March 25, 2025 18:13

Revisions

  1. gmolveau revised this gist Jan 28, 2020. No changes.
  2. gmolveau revised this gist Jan 27, 2020. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions recutils_tutorial_example.md
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,11 @@

    https://www.gnu.org/software/recutils/

    On mac : `brew install recutils`
    > GNU Recutils is a set of tools and libraries to access human-editable, plain text databases called recfiles.
    > add this to a new file `books.rec`
    TO install on mac : `brew install recutils`

    > add this to a new file named `books.rec`
    ```bash
    %rec: Book
  3. gmolveau revised this gist Jan 27, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion recutils_tutorial_example.md
    Original file line number Diff line number Diff line change
    @@ -50,7 +50,7 @@ recsel -t Book -e "Location = 'loaned'" -P Title books.rec

    ```bash
    #recins -t TYPE (%rec) -f FIELD (Title) -v VALUE file.rec
    recins -t Book -f Title -v "TheNewBook" books.rec
    recins -t Book -f Title -v "TheNewBook" -f Author -v "OuiLaVoix" -f Author -v "LaPetiteVoix" books.rec
    ```

    - update
  4. gmolveau renamed this gist Jan 27, 2020. 1 changed file with 0 additions and 0 deletions.
  5. gmolveau created this gist Jan 27, 2020.
    71 changes: 71 additions & 0 deletions rectutils_tutorial_example.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    # recutils tutorial example

    https://www.gnu.org/software/recutils/

    On mac : `brew install recutils`

    > add this to a new file `books.rec`
    ```bash
    %rec: Book
    #%key: Id
    #%type: Id int
    #%auto: Id
    #%unique: ISBN
    %mandatory: Title
    %type: Location enum loaned home unknown
    %doc:
    + A book in my personal collection.

    Title: GNU Emacs Manual
    Author: Richard M. Stallman
    Publisher: FSF
    Location: home

    Title: The Colour of Magic
    Author: Terry Pratchett
    Location: loaned

    Title: Mio Cid
    Author: Anonymous
    Location: home

    Title: chapters.gnu.org administration guide
    Author: Nacho Gonzalez
    Author: Jose E. Marchesi
    Location: unknown

    Title: Yeelong User Manual
    Location: home
    ```

    - select

    ```bash
    # recsel -t TYPE (%rec) -e EXPRESSION -P PRINT_ONLY_THESE_FIELDS file.rec
    recsel -t Book -e "Location = 'loaned'" -P Title books.rec
    ```

    - insert

    ```bash
    #recins -t TYPE (%rec) -f FIELD (Title) -v VALUE file.rec
    recins -t Book -f Title -v "TheNewBook" books.rec
    ```

    - update

    ```bash
    # recset -t TYPE (%rec) -f FIELD -d (DELETE_THIS_FIELD) file.rec
    recset -t Book -f Publisher -d books.rec

    # recset -t TYPE (%rec) -e EXPRESSSION -f FIELD -S CREATE_FIELD_WITH_VALUE_OR_REPLACE file.rec
    recset -t Book -e "Location = 'loaned'" -f LoanedAt -S "$(date)" books.rec
    ```

    - delete

    ```bash
    # recdel -c (COMMENT INSTEAD OF DELETE) -t TYPE (%rec) -e EXPRESSION file.rec
    recdel -c -t Book -e "Location = 'loaned'" books.rec
    ```