$darkmode
Elektra 0.11.0
kdb-get(1) -- Get the value of a key stored in the key database

SYNOPSIS

kdb get <key name>

Where key name is the name of the key.

DESCRIPTION

This command is used to retrieve the value of a key.

If you enter a key name starting with a leading /, then a cascading lookup will be performed in order to attempt to locate the key. In this case, using the -v option allows the user to see the full key name of the key if it is found.

LIMITATIONS

Only keys within the mount point or below the <key name> will be considered during a cascading lookup. A workaround is to pass the -a option. Use the command kdb get -v <key name> to see if an override or a fallback was considered by the lookup.

RETURN VALUES

This command will return the following values as an exit status:

OPTIONS

EXAMPLES

1 # Backup-and-Restore: user:/tests/get/examples
2 
3 # We use the `dump` plugin, since some storage plugins, e.g. INI,
4 # create intermediate keys.
5 sudo kdb mount get.ecf user:/tests/get/examples/kdb-get dump
6 sudo kdb mount get.ecf spec:/tests/get/examples/kdb-get dump
7 
8 # Create the keys we use for the examples
9 kdb set user:/tests/get/examples/kdb-get/key myKey
10 kdb meta-set spec:/tests/get/examples/kdb-get/anotherKey default defaultValue
11 
12 # To get the value of a key:
13 kdb get user:/tests/get/examples/kdb-get/key
14 #> myKey
15 
16 # To get the value of a key using a cascading lookup:
17 kdb get /tests/get/examples/kdb-get/key
18 #> myKey
19 
20 # To get the value of a key without adding a newline to the end of it:
21 kdb get -n /tests/get/examples/kdb-get/key
22 #> myKey
23 
24 # To explain why a specific key was used (for cascading keys):
25 kdb get -v /tests/get/examples/kdb-get/key
26 #> got 3 keys
27 #> searching spec:/tests/get/examples/kdb-get/key, found: <nothing>, options: KDB_O_CALLBACK
28 #> searching proc:/tests/get/examples/kdb-get/key, found: <nothing>
29 #> searching dir:/tests/get/examples/kdb-get/key, found: <nothing>
30 #> searching user:/tests/get/examples/kdb-get/key, found: user:/tests/get/examples/kdb-get/key
31 #> The resulting keyname is user:/tests/get/examples/kdb-get/key
32 #> The resulting value size is 6
33 #> myKey
34 
35 # Output if only a default value is set for a key:
36 kdb get -v /tests/get/examples/kdb-get/anotherKey
37 #> got 3 keys
38 #> searching spec:/tests/get/examples/kdb-get/anotherKey, found: spec:/tests/get/examples/kdb-get/anotherKey, options: KDB_O_CALLBACK
39 #> The key was not found in any other namespace, taking the default
40 #> The resulting keyname is default:/tests/get/examples/kdb-get/anotherKey
41 #> The resulting value size is 13
42 #> defaultValue
43 
44 kdb rm user:/tests/get/examples/kdb-get/key
45 kdb rm spec:/tests/get/examples/kdb-get/anotherKey
46 sudo kdb umount user:/tests/get/examples/kdb-get
47 sudo kdb umount spec:/tests/get/examples/kdb-get

To use bookmarks:
kdb get +kdb/format

This command will actually get user:/sw/elektra/kdb/#0/current/format if the bookmarks commands from kdb-set(1) man pages are executed before.

SEE ALSO