GDBMTOOL(1)
π NAME π
gdbmtool β the gdbmtool(1) page, bestie. It's the little utility that lets you peek at and mess with a GDBM database. No cap.
πΈ SYNOPSIS πΈ
gdbmtool [-lmNnqrs] [-b SIZE] [-c SIZE] [-f FILE] [--block-size=SIZE]
[--cache-size=SIZE] [--file FILE] [--newdb] [--no-lock] [--no-mmap]
[--norc] [--quiet] [--read-only] [--synchronize] [DBFILE] [COMMAND [;
COMMAND...]]
gdbmtool [-Vh] [--help] [--usage] [--version]
β¨ DESCRIPTION β¨
Okay so gdbmtool is literally your little bestie for looking at a GDBM database that already exists, or making a brand new one from scratch. Iconic behavior. π
The DBFILE argument is the name of the database you wanna open. If you don't give one? It just uses the default name junk.gdbm instead. And if the database you named doesn't exist yet β no stress β it gets created. π«Ά
Got an existing database and you want it completely wiped (like, every single record gone)? That's what the --newdb option is for (more on that below).
Unless you pass the -N (--norc) option, right after startup gdbmtool goes looking for a file named .gdbmtoolrc. It checks the current working directory first, and if it's not there, it checks the home directory of whoever started the program. If it finds it, that file gets read and interpreted as a whole list of gdbmtool commands. β¨
Then gdbmtool kicks off a loop where it reads commands from standard input, runs them, and prints the results on standard output. And if standard input is hooked up to a console, congrats, you're in interactive mode. π
The program dips out when you give the quit command, or when it hits end-of-file on standard input.
You can also just hand it commands on the command line, after the DBFILE argument. In that case it interprets them right away and doesn't bother trying to read more commands from standard input.
If you're giving it several commands, separate them with semicolons β and make sure they're properly escaped or quoted so the shell doesn't get its grubby little hands on them first. π
A gdbmtool command is a command verb, optionally followed by one or more arguments, separated by any amount of white space. And the verb can be typed out in full or abbreviated β as long as that abbreviation doesn't match any other verb. Slay, honestly.
Any run of non-whitespace characters after the command verb counts as an argument. If your argument has whitespace or unprintable characters in it, wrap it in double quotes. And inside those double quotes, the usual escape sequences are understood, like so:
\aβ Audible bell character (ASCII 7)\bβ Backspace character (ASCII 8)\fβ Form-feed character (ASCII 12)\nβ Newline character (ASCII 10)\rβ Carriage return character (ASCII 13)\tβ Horizontal tabulation character (ASCII 9)\vβ Vertical tabulation character (ASCII 11)\\β Single slash
And on top of that? A backslash immediately followed by the end-of-line character effectively removes that character, which means you can split long arguments across several input lines. Obsessed. π
π₯ OPTIONS π₯
-b,--block-size=SIZEβ Set block size.-c,--cache-size=SIZEβ Set cache size.-f,--file=FILEβ Read commands from FILE, instead of from the standard input.-l,--no-lockβ Disable file locking.-m,--no-mmapβ Do not usemmap(2).-n,--newdbβ Create the database, truncating it if it already exists.-q,--quietβ Don't print initial banner.-r,--read-onlyβ Open database in read-only mode.-s,--synchronizeβ Synchronize to disk after each write.-h,--helpβ Print a short usage summary.--usageβ Print a list of available options.-V,--versionβ Print program version
π¦ SHELL COMMANDS π¦
availβ Print the avail list.bucket NUMβ Print the bucket number NUM and set is as the current one.cacheβ Print the bucket cache.closeβ Close the currently open database.countβ Print the number of entries in the database.currentβ Print the current bucket.delete KEYβ Delete record with the given KEY.dirβ Print hash directory.downgradeβ Downgrade the database from the extended numsync format to the standard format.export FILE-NAME [truncate] [binary|ascii]β Export the database to the flat file FILE-NAME. This is equivalent togdbm_dump(1). This command will not overwrite an existing file, unless thetruncateparameter is also given. Another optional parameter determines the type of the dump (*note Flat files::). By default, ASCII dump will be created.fetch KEYβ Fetch and display the record with the given KEY.firstβ Fetch and display the first record in the database. Subsequent records can be fetched using thenextcommand (see below).hash KEYβ Compute and display the hash value for the given KEY.headerβ Print file header.helpor?β Print a concise command summary, showing each command letter and verb with its parameters and a short description of what it does. Optional arguments are enclosed in square brackets.historyβ Shows the command history list with line numbers. This command is available only if the program was compiled with GNU Readline.history COUNT.β Shows COUNT latest commands from the command history.history N COUNT.β Shows COUNT commands from the command history starting with *N*th command.import FILE-NAME [replace] [nometa]β Import data from a flat dump file FILE-NAME. If thereplaceargument is given, any records with the same keys as the already existing ones will replace them. Thenometaargument turns off restoring meta-information from the dump file.listβ List the contents of the database.next [KEY]β Sequential access: fetch and display the next record. If the KEY is given, the record following the one with this key will be fetched.open FILEβ Open the database file FILE. If successful, any previously open database is closed. Otherwise, if the operation fails, the currently opened database remains unchanged. This command takes additional information from the variablesopen,lock,mmap, andsync. See the section VARIABLES, for a detailed description of these.quitβ Close the database and quit the utility.reorganizeβ Reorganize the database.set [VAR=VALUE...]β Without arguments, lists variables and their values. If arguments are specified, sets variables. Boolean variables can be set by specifying variable name, optionally prefixed withno, to set it to false.snapshot FILE FILEβ Analyzes two database snapshots and selects the most recent of them. In case of error, prints a detailed diagnostics. Use this command to manually recover from a crash. For details, please refer to the chapter Crash Tolerance in the GDBM manual.source FILEβ Read commands from the given FILE.statusβ Print current program status.store KEY DATAβ Store the DATA with the given KEY in the database. If the KEY already exists, its data will be replaced.syncβ Synchronize the database file with the disk storage.upgradeβ Upgrade the database from the standard to the extended numsync format.unset VARIABLE...β Unsets listed variables.versionβ Print the version ofgdbm.
π DATA DEFINITIONS π
The define statement is the whole mechanism for defining key or content structures. Think of it as being similar to a C struct declaration:
define key|content { defnlist }
The defnlist is a comma-separated list of member declarations. And here's the cute part: within defnlist, the newline character loses its special meaning as the command terminator. So every declaration can live on its own separate line, and you can sprinkle in however many comments you want to document the definition. π
Every declaration has one of these two formats:
type name
type name [N]
where type is a data type and name is the member name. That second format defines the member name as an array of N elements of type. πΈ
Here are the supported types:
charβ single byte (signed)shortβ signed short integerushortβ unsigned short integerintβ signed integerunsignedβ unsigned integeruintβ dittolongβ signed long integerulongβ unsigned long integerllongβ signed long long integerullongβ unsigned long long integerfloatβ a floating point numberdoubleβ double-precision floating point numberstringβ array of characters (see the NOTE below)stringzβ null-terminated string of characters
And these alignment declarations can be used within defnlist:
offset Nβ The next member begins at offset N.pad Nβ Add N bytes of padding to the previous member.
For example:
define content {
int status,
pad 8,
char id[3],
stringz name
}
Now, if you wanna define data that's just a single data member, you can use this simplified construct instead:
define key|content type
where type is one of the types we just talked about. π
NOTE: the string type can reasonably be used only if it is the last or the only member of the data structure. That's because it provides no information about the number of elements in the array, so it's interpreted to contain all bytes up to the end of the datum. Watch out for that one, bestie. π
π VARIABLES π
okay so these are the little knobs and dials you can tweak, bestie. periodt.
confirm, boolean β whether to ask for confirmation before certain destructive operations, such as truncating the existing database. Default istrue. safety first, fr fr π«Άps1, string β primary prompt string. Its value can contain conversion specifiers, consisting of the%character followed by another character. These specifiers are expanded in the resulting prompt as follows:%fβ name of the db file%pβ program name%Pβ package name (gdbm)%_β horizontal space (ASCII 32)%vβ program version%%β%
The default prompt is %p>%_. iconic β¨
ps2, string β secondary prompt. Seeps1for a description of its value. This prompt is displayed before reading the second and subsequent lines of a multi-line command.
The default value is %_>%_. multi-line slay π
delim1, string β a string used to delimit fields of a structured datum on output (see the section DATA DEFINITIONS). Default is,(a comma). This variable cannot be unset. locked in πdelim2, string β a string used to delimit array items when printing a structured datum. Default is,(a comma). This variable cannot be unset. also locked in πpager, string β the name and command line of the pager program to pipe output to. This program is used in interactive mode when the estimated number of output lines is greater than the number of lines on your screen. The default value is inherited from the environment variablePAGER. Unsetting this variable disables paging. pager vibes πquiet, boolean β whether to display welcome banner at startup. This variable should be set in a startup script file. shhh π€«
The following variables control how the database is opened:
cachesize, numeric β sets the cache size. By default this variable is not set. not set by default π§blocksize, numeric β sets the block size. Unset by default. also unset π§±open, string β open mode. The following values are allowed:newdbβ truncate the database if it exists or create a new one. Open it in read-write mode. destructive, bestie! πwrcreatorrwβ open the database in read-write mode. Create it if it does not exist. This is the default. default energy πreaderorreadonlyβ open the database in read-only mode. Signal an error if it does not exist. look but don't touch π
filemode, octal β sets the file mode for newly created database files. Default is0644. permissions, but make it fashion πlock, boolean β lock the database. This is the default. locked and loaded πmmap, boolean β use memory mapping. This is the default. memory mapping main character energy π§coalesce, boolean β when set, this option causes adjacent free blocks to be merged which allows for more efficient memory management at the expense of a certain increase in CPU usage. trade-off alert βοΈcentfree, boolean β enables central free block pool. This causes all free blocks of space to be placed in the global pool, thereby speeding up the allocation of data space. speed boost π
π SEE ALSO π
gdbm_dump(1), gdbm_load(1), gdbm(3). go read these too, bestie π
π REPORTING BUGS π
Report bugs to <bug-gdbm@gnu.org>. they wanna hear from you π¬
π COPYRIGHT π
Copyright Β© 2013-2021 Free Software Foundation, Inc License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
periodt π
ok bye bestie! this was GDBMTOOL(1) from GDBM, dated August 1, 2021 πβ¨π¦
π¦ where this page comes from
- debian bookworm: gdbmtool 1.23-3 Β· GPL-3.0-or-later
- ubuntu jammy: gdbmtool 1.23-1 Β· GPL-3.0-or-later
- Copyright (C) 2013-2022 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms