Skip to content

Commit 26ffc12

Browse files
authored
bash-db (#87)
* add bash-db * format post --------- Co-authored-by: dskvr <[email protected]>
1 parent 6ada1aa commit 26ffc12

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

Diff for: _posts/2024-03-26-bash-db.md

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
layout: post
3+
title: "bash-db"
4+
description: "Very simple key-value store for bash"
5+
category: bash
6+
tags: ['utils', 'utility', 'db']
7+
---
8+
9+
bash-db
10+
=======
11+
12+
Very simple Key-Value database on bash script. Depends on pre-installed software only (tested on Ubuntu 14.04 LTS):
13+
* sed
14+
* bash
15+
* grep
16+
* base64
17+
* xargs
18+
19+
Install
20+
=======
21+
22+
## bpkg (global package)
23+
```bash
24+
bpkg install reddec/bash-db
25+
```
26+
27+
## Make (/usr/local/bin)
28+
```bash
29+
make install
30+
```
31+
32+
## Manual Installation
33+
```bash
34+
git clone https://github.com/reddec/bash-db
35+
cd bash-db
36+
chmod +x db.sh
37+
cp db.sh /usr/local/bin/db
38+
```
39+
40+
Usage
41+
=======
42+
43+
## Command-line Tool
44+
`db <method> <database> [arguments...]`
45+
46+
Methods:
47+
48+
### PUT
49+
50+
Insert or update record.
51+
52+
| Arg | Description |
53+
|-------------------| -------------|
54+
| `key` (required) | Unique key. Can be used any value (also spaces if value in bracets)
55+
| `value` (optional)| Value of record. Can be used any value (also spaces if value in bracets). If value not set, STDIN will be used.
56+
57+
#### Example:
58+
59+
```bash
60+
db put test.db name 'Red Dec'
61+
```
62+
63+
### GET
64+
65+
Get value of record by key
66+
67+
| Arg | Description |
68+
|-------------------| -------------|
69+
| `key` (required) | Unique key. Can be used any value (also spaces if value in bracets)
70+
71+
#### Example:
72+
73+
```bash
74+
db get test.db name
75+
```
76+
77+
### LIST
78+
79+
Get all keys in database
80+
81+
**No arguments**
82+
83+
#### Example:
84+
85+
```bash
86+
db list test.db
87+
```
88+
89+
### LAST
90+
91+
Get the value of the last added record
92+
93+
**No arguments**
94+
95+
#### Example:
96+
97+
```bash
98+
db last test.db
99+
```
100+
101+
### DELETE
102+
103+
Delete record by key
104+
105+
| Arg | Description |
106+
|-------------------| -------------|
107+
| `key` (required) | Unique key. Can be used any value (also spaces if value in bracets)
108+
109+
#### Example:
110+
111+
```bash
112+
db delete test.db name
113+
```
114+
115+
## Links
116+
- [Source Code (GitHub)](https://github.com/reddec/bash-db)
117+
- [Author: Aleksandr Baryshnikov](https://github.com/reddec)
118+
119+
{% include JB/setup %}

0 commit comments

Comments
 (0)