Initially, the idea was to write a script that would help to simply and universally work with certain groups of data in home scripts-wrote-and-forgot.
And here you have a
nice and beautiful scary and terrible, but simple and convenient database for storing a
small amount of data in simple home scripts.
TBDB, also known as
Terrible Bash Data Base .
The base engine consists of a single bash script.
3 commands are supported - select, insert, delete.
The data is stored in a file, each row is a record, the columns are separated by tabs (\ t). Since the contents of the table can contain characters such as line breaks and tabs, it is possible to store data in base64.
')
How to work with her?
The general command syntax is:
./tbdb.sh DBFile [modifers] [command] [parameters]Select command
1) Sampling by line numbers
./tbdb.sh DBFile select 1,3,5 line 2
Displays all values in columns 1, 3, and 5 in the second row.
2) Sampling by content
./tbdb.sh DBFile select 1,3,5 where 3 = text
Displays all values in columns 1, 3, and 5 in rows, where the third cell contains “text”
Insert command
./tbdb.sh DBFile insert field1 field2 field3
Add a line with three cells to the DBFile file, fill them in as field1, field2, field3.
Delete command
./tbdb.sh DBFile delete line 2
Delete the second line.
There are also
modifiers"-n" - gives before each line the line number in the database.
"-b" - makes base64 work with data.
Of course, this is not the sql queries;)
Just for fun!
Backlit source code:
dl.dropbox.com/u/3926517/habr/tbdb.htmlAnd the source itself, download:
dl.dropbox.com/u/3926517/habr/tbdb.sh