https://www.gnu.org/software/recutils/
GNU Recutils is a set of tools and libraries to access human-editable, plain text databases called recfiles.
TO install on mac : brew install recutils
add this to a new file named
books.rec
%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
# recsel -t TYPE (%rec) -e EXPRESSION -P PRINT_ONLY_THESE_FIELDS file.rec
recsel -t Book -e "Location = 'loaned'" -P Title books.rec
- insert
#recins -t TYPE (%rec) -f FIELD (Title) -v VALUE file.rec
recins -t Book -f Title -v "TheNewBook" -f Author -v "OuiLaVoix" -f Author -v "LaPetiteVoix" books.rec
- update
# 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
# recdel -c (COMMENT INSTEAD OF DELETE) -t TYPE (%rec) -e EXPRESSION file.rec
recdel -c -t Book -e "Location = 'loaned'" books.rec