bash-db

Very simple key-value store for bash

bash-db

Very simple Key-Value database on bash script. Depends on pre-installed software only (tested on Ubuntu 14.04 LTS):

  • sed
  • bash
  • grep
  • base64
  • xargs

Install

bpkg (global package)

bpkg install reddec/bash-db

Make (/usr/local/bin)

make install

Manual Installation

git clone https://github.com/reddec/bash-db
cd bash-db
chmod +x db.sh
cp db.sh /usr/local/bin/db

Usage

Command-line Tool

db <method> <database> [arguments...]

Methods:

PUT

Insert or update record.

Arg Description
key (required) Unique key. Can be used any value (also spaces if value in bracets)
value (optional) Value of record. Can be used any value (also spaces if value in bracets). If value not set, STDIN will be used.

Example:

db put test.db name 'Red Dec'

GET

Get value of record by key

Arg Description
key (required) Unique key. Can be used any value (also spaces if value in bracets)

Example:

db get test.db name

LIST

Get all keys in database

No arguments

Example:

db list test.db

LAST

Get the value of the last added record

No arguments

Example:

db last test.db

DELETE

Delete record by key

Arg Description
key (required) Unique key. Can be used any value (also spaces if value in bracets)

Example:

db delete test.db name

Published: March 26 2024

blog comments powered by Disqus