Skip to content

Instantly share code, notes, and snippets.

@nyukhalov
Last active May 4, 2018 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nyukhalov/ebe4c499ba97973b7dba74b6f8f43307 to your computer and use it in GitHub Desktop.
Save nyukhalov/ebe4c499ba97973b7dba74b6f8f43307 to your computer and use it in GitHub Desktop.
The simplest key-value db written in shell
#!/bin/bash
# Usage
# > ./shdb.sh db_set foo 3
# > ./shdb.sh db_set bar 5
# > ./shdb.sh db_get foo
# 3
db_set() {
echo "$1,$2" >> database
}
db_get() {
grep "^$1," database | sed s/^$1,// | tail -n 1
}
"$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment