Last active
May 4, 2018 05:03
-
-
Save nyukhalov/ebe4c499ba97973b7dba74b6f8f43307 to your computer and use it in GitHub Desktop.
The simplest key-value db written in shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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