GDBMTOOL(1)

πŸ“¦
version 1.26 Β· 3 versions
, in alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– GDBMTOOL β€” the gdbmtool page, bestie edition πŸ’–

okay so this is GDBMTOOL(1) from the GDBM User Reference β€” like, the manual for gdbmtool. she's long, she's iconic, she's got range. grab a snack. πŸ“


✨ NAME ✨

gdbmtool β€” examine and modify a GDBM database πŸ’…


🌸 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]

like. look at her go. πŸ¦‹


πŸŽ€ DESCRIPTION πŸŽ€

The gdbmtool utility is literally the whole moment β€” it lets you view and modify an existing GDBM database, or create a brand new one. main character energy, fr fr. πŸ‘‘

The DBFILE argument supplies the name of the database to open. If you don't give one, the default name junk.gdbm is used instead. And if the named database doesn't exist? she gets created. no drama. ✨

An existing database can be cleared β€” like, every single record removed from it β€” using the --newdb option (see below). that's a full reset bestie, be careful 😭

Unless the -N (--norc) option is given, after startup gdbmtool goes looking for a file named .gdbmtoolrc, first in the current working directory, and, if it's not found there, in the home directory of the user who started the program. If it's found, this file gets read and interpreted as a list of gdbmtool commands. it's giving ✨personalized✨

Then gdbmtool starts a loop, in which it reads commands from the standard input, executes them and prints the results on the standard output. If the standard input is attached to a console, the program runs in interactive mode. 🫢

The program terminates when the quit command is given, or end-of-file is detected on its standard input. bye bestie πŸ’œ

Commands can also be specified in the command line, after the DBFILE argument. In this case, they will be interpreted without attempting to read more commands from the standard input. one-shot mode, slay.

If several commands are supplied, they must be separated by semicolons (properly escaped or quoted, in order to prevent them from being interpreted by the shell). don't let the shell steal your semicolons, that's not her job πŸ™ˆ

A gdbmtool command consists of a command verb, optionally followed by one or more arguments, separated by any amount of white space. A command verb can be entered either in full or in an abbreviated form, as long as that abbreviation does not match any other verb. so q works until somebody else also starts with q, iykyk.

Any sequence of non-whitespace characters appearing after the command verb forms an argument. If the argument contains whitespace or unprintable characters it must be enclosed in double quotes. Within double quotes the usual escape sequences are understood, as shown in the list below:

  • \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

In addition, a backslash immediately followed by the end-of-line character effectively removes that character, allowing to split long arguments over several input lines. line continuation, we love her πŸ’…


🌈 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 use mmap(2). 🚫
  • -n, --newdb β€” Create the database, truncating it if it already exists. ⚠️ yes, truncating. she's starting fresh and she means it.
  • -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 πŸ‘‘

okay this is the good part. here's every command, no skips, periodt.

  • avail β€” Print the avail list. πŸ“ƒ
  • bucket NUM β€” Print the bucket number NUM and set is as the current one. (yes, "set is as" β€” that's the original wording, we don't edit the ancestors πŸ’€)
  • 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 to gdbm_dump(1).

This command will not overwrite an existing file, unless the truncate parameter 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 the next command (see below). πŸ₯‡
  • hash KEY β€” Compute and display the hash value for the given KEY. #️⃣
  • header β€” Print file header. πŸ“„
  • help or ? β€” 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 the replace argument is given, any records with the same keys as the already existing ones will replace them. The nometa argument 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 variables open, lock, mmap, and sync. 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 with no, 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 of gdbm. 🏷️

πŸ¦‹ PIPES πŸ¦‹

A command can be followed by a pipe sign (|) and a shell command. The meaning is the same as in Bourne shell: the output of the gdbmtool command is connected to the input of a shell command specified on the right side of |. In this case pager is disabled. πŸ”—


πŸ’œ DATA DEFINITIONS πŸ’œ

The define statement provides a mechanism for defining key or content structures. It is similar to the C struct declaration:

define key|content { defnlist }

The defnlist is a comma-separated list of member declarations. Within defnlist the newline character looses its special meaning as the command terminator, so each declaration can appear on a separate line and arbitrary number of comments can be inserted to document the definition. ✍️

Each declaration has one of the following formats

type name
type name [N]

where type is a data type and name is the member name. The second format defines the member name as an array of N elements of type. 🧱

The supported types are:

  • char β€” single byte (signed)
  • short β€” signed short integer
  • ushort β€” unsigned short integer
  • int β€” signed integer
  • unsigned β€” unsigned integer
  • uint β€” ditto
  • long β€” signed long integer
  • ulong β€” unsigned long integer
  • llong β€” signed long long integer
  • ullong β€” unsigned long long integer
  • float β€” a floating point number
  • double β€” double-precision floating point number
  • string β€” array of characters (see the NOTE below)
  • stringz β€” null-terminated string of characters

The following 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
}

To define data consisting of a single data member, the following simplified construct can be used:

define key|content type

where type is one of the types discussed above. ✨

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 is interpreted to contain all bytes up to the end of the datum. 😭 she doesn't know where she ends, so put her last.

(part 1 done bestie β€” there's more coming, don't go anywhere 🫢)

🌸 VARIABLES 🌸

okay bestie, this is the fun part β€” you get to tune your gdbmtool session πŸ’… these are the variables you can set, and honestly they're giving control-freak-but-make-it-adorable.

  • confirm, boolean β€” do we ask before we do something chaotic?? like, y'know, truncating your whole existing database 😭 set this to true and you get a lil "u sure?" moment first. Default is true. And yes, bestie, you want it true.
  • ps1, string β€” the primary prompt string ✨ its value can contain conversion specifiers, which are the % character followed by another character. Those specifiers get expanded in the resulting prompt like this:
    • %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>%_.

  • ps2, string β€” the secondary prompt 🌸 check ps1 for how its value works, same deal. This one shows up before it reads the second and subsequent lines of a multi-line command. It's the "…okay and then?" prompt.

The default value is %_>%_.

  • delim1, string β€” a string used to delimit fields of a structured datum on output (peep the section DATA DEFINITIONS).

Default is , (a comma). ⚠️ this variable cannot be unset.

  • delim2, string β€” a string used to delimit array items when printing a structured datum.

Default is , (a comma). ⚠️ this variable cannot be unset either.

  • pager, string β€” the name and command line of the pager program that output gets piped 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. (iykyk β€” it's the less situation.)

The default value is inherited from the environment variable PAGER. Unsetting this variable disables paging.

  • quiet, boolean β€” whether to display the welcome banner at startup πŸŽ€ this variable should be set in a startup script file. no banner, no vibes, just business.

and now the ones that control how the database gets opened β€” the ✨main character✨ settings:

  • cachesize, numeric β€” sets the cache size. By default this variable is not set.
  • blocksize, numeric β€” sets the block size. Unset by default.
  • 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.
    • wrcreat or rw β€” open the database in read-write mode. Create it if it does not exist. This is the default.
    • reader or readonly β€” open the database in read-only mode. Signal an error if it does not exist. πŸ’€
  • filemode, octal β€” sets the file mode for newly created database files. Default is 0644.
  • lock, boolean β€” lock the database. This is the default. πŸ”’
  • mmap, boolean β€” use memory mapping. This is the default.
  • 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-offs, babe.
  • 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. ⚑ slay.

πŸ‘€ SEE ALSO πŸ‘€

gdbm_dump(1), gdbm_load(1), gdbm(3).

go read those too bestie, they're the rest of the lore πŸ“š


πŸ› REPORTING BUGS πŸ›

Report bugs to <bug-gdbm@gnu.org>.

found something broken?? tell the devs, not me, i'm just the messenger πŸ™ˆ


Copyright Β© 2013-2025 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.


and that's a wrap on GDBMTOOL(1), bestie πŸŽ€ this whole thing is from the GDBM package, version-dated March 6, 2025 β€” go forth and database responsibly, mwah πŸ’–βœ¨πŸ¦‹