dbm is a very simple Perl 5 script which allows you to manipulate/read DBM files from the command line, or using your favourite editor. It supports any DBM formats which your system has Perl modules for.
Have a look at the change log.
If you don't know, you probably don't need this program. If you're curious, try typing perldoc perltie and perldoc AnyDBM_File.
Download the source code and optionally place it somewhere on your executable search path for convenience. Then invoke it as in the following examples (which all assume that the name of the DBM file is foo).
To create an empty database:
Note that in older versions, the database would automatically be created if it didn't already exist.
$ dbm foo init
To set a key value pair:
$ dbm foo set key1 val1
To set several key value pairs at once:
$ dbm foo set key1 val1 key2 val2
To delete a key value pair:
$ dbm foo delete key
To delete several key value pairs at once:
$ dbm foo delete key1 key2 key3
To list all key value pairs:
$ dbm foo list
To list selected key value pairs:
$ dbm foo list key1 key2 key3
To edit all key value pairs with your favourite editor (as determined by $EDITOR or $VISUAL):
$ dbm foo edit
To clear all key value pairs from the file:
$ dbm foo clear everything yes really
The default DBM file type is whatever the AnyDBM_File Perl module on your system decides it to be (type perldoc AnyDBM_File for more information). If you want to use a different format to the default, replace dbm with dbm -t dbm_type in the above examples, where dbm_type is something like DB_File, NDBM, or GDBM.
Note that some of the operations have synonyms, so you can use whichever you find easiest to remember; type dbm with no arguments to find out more details.
That's all there is to it!
As with all my software, all suggestions / bug reports / patches (unified or context diff only please) are very welcome; please contact me by e-mail.
Last updated: Sat Nov 1 22:37:39 2003
© 1995-2003
Adam Spiers <adam@spiers.net>