manpagez: man pages & more
info gdbm
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.2 testgdbm interactive mode

After successful startup, testgdbm starts a loop, in which it reads commands from the user, executes them and prints the results on the standard output. If the standard input is attached to a console, testgdbm runs in interactive mode, which is indicated by its prompt:

testgdbm> _

The utility finishes when it reads the ‘quit’ command (see below) or detects end-of-file on its standard input, whichever occurs first.

A testgdbm command consists of a command verb, optionally followed by one or two 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. For example, ‘co’ can be used instead of ‘count’ and ‘ca’ instead of ‘cache’. Furthermore, many command verbs also have single-letter forms, called command letters.

An argument is any sequence of non-whitespace characters. Notice, that currently there is no way to enter arguments containing white space. This limitation will be removed in future releases.

Each command takes at most two formal parameters, which can be optional or mandatory. If the number of actual arguments is less than the number of mandatory parameters, testgdbm will prompt you to supply missing arguments. For example, the ‘store’ command takes two mandatory parameters, so if you invoked it with no arguments, you would be prompted twice to supply the necessary data, as shown in example below:

testgdbm> store
key> three
data> 3

However, such prompting is possible only in interactive mode. In non-interactive mode (e.g. when running a script), all arguments must be supplied with each command, otherwise testgdbm will report an error and exit immediately.

Some commands produce excessive amounts of output. To help you follow it, testgdbm uses a pager utility to display such output. The name of the pager utility is taken from the environment variable PAGER. The pager is invoked only in interactive mode and only if the estimated number of output lines is greater then the number of lines on your screen.

Many of the testgdbm commands operate on database key and data values. The utility assumes that both keys and data are ASCII strings, either nul-terminated or not. By default, it is assumed that strings are nul-terminated. You can change this by using z (key-zero, for keys) and Z (data-zero, for data) commands.

The following table summarizes all available commands:

command verb: count
command abbrev: co
command letter: c

Print the number of entries in the database.

command verb: delete key
command abbrev: de key
command letter: d key

Delete entry with a given key

command verb: export file-name [truncate]
command abbrev: e file-name [truncate]

Export the database to the flat file file-name. See section Export and Import, for a description of the flat file format and its purposes. This command will not overwrite an existing file, unless the word ‘truncate’ is given as its second argument.

See also Export a database into a portable format..

command verb: fetch key
command abbrev: fe key
command letter: f key

Fetch and display a record with the given key.

command verb: import file-name [replace]
command abbrev: i file-name [replace]

Import data from a flat dump file file-name (see section Export and Import). If the word ‘replace’ is given as the second argument, any records with the same keys as the already existing ones will replace them.

command verb: list
command abbrev: l

List the contents of the database (see pager).

command verb: next [key]
command abbrev: n [key]

Sequential access: fetch and display a next record. If key is given, a record following one with this key will be fetched. Otherwise, the key supplied by the latest 1, 2 or n command will be used.

See also first, below.

See section Sequential access to records., for more information on sequential access.

command verb: quit
command abbrev: q

Close the database and quit the utility.

command verb: store key data
command abbrev: sto key data
command letter: s key data

Store the data with key in the database. If key already exists, its data will be replaced.

command verb: first
command abbrev: fi
command letter: 1

Fetch and display the first record in the database. Subsequent records can be fetched using next command (see above). See section Sequential access to records., for more information on sequential access.

command verb: read file [replace]
command abbrev: rea file [replace]
command letter: < file [replace]

Read entries from file and store them in the database. If the word ‘replace’ is given as the second argument, any existing records with matching keys will be replaced.

command verb: reorganize
command abbrev: reo
command letter: r

Reorganize the database (see section Database reorganization.).

command verb: key-zero
command abbrev: k
command letter: z

Toggle key nul-termination. Use status to inspect the current state. See nul-termination.

command verb: avail
command abbrev: a
command letter: A

Print the avail list.

command verb: bucket
command abbrev: b
command letter: B

Print the bucket number num.

command verb: current
command abbrev: cu
command letter: C

Print the current bucket.

command verb: dir
command abbrev: di
command letter: D

Print hash directory.

command verb: header
command abbrev: hea
command letter: F

Print file header.

command verb: hash key
command abbrev: ha key
command letter: H key

Compute and display the hash value for the given key.

command verb: cache
command abbrev: ca
command letter: K

Print the bucket cache.

command verb: status
command abbrev: sta
command letter: S

Print current program status. The following example shows the information displayed:

Database file: junk.gdbm
Zero terminated keys: yes
Zero terminated data: yes
command verb: version
command abbrev: v

Print the version of gdbm.

command verb: data-zero
command abbrev: da
command letter: Z

Toggle data nul-termination. Use status to examine the current status.

See nul-termination.

command verb: help
command abbrev: hel
command letter: ?

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.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on December 2, 2011 using texi2html 5.0.

© 2000-2019
Individual documents may contain additional copyright information.