BSEARCH(1) General Commands Manual BSEARCH(1)

# [NAME](#NAME)

`bsearch` — manages one-time passwords

# [SYNOPSIS](#SYNOPSIS)

`bsearch` \[`-KVvh`] \[`-b` `block-size`] \[`-m` `max-cache-size`] `file` `[key ...]`

# [DESCRIPTION](#DESCRIPTION)

The `bsearch` program performs binary searches of `file` which must be a sorted flat text file.

Each line is a record. Each record starts with a key that is optionally followed by whitespace and a value. Whitespace may be quoted with a backslash, but newline and carriage-return characters must be quoted in some other manner (e.g., as backslash-n and backslash-r). Escapes are not interpreted nor removed.

If no key arguments are given on the comman-line, then keys will be read from standard input.

By default only values are printed to standard output. Use the -K option to also print keys. The exit status will be non-zero if any key lookups fail.

Options are:

[`-K`](#K)

Print keys.

[`-V`](#V)

Don't print values.

[`-h`](#h)

Print usage and exit.

[`-v`](#v)

Print statistic and debug information to standard error. `file` A sorted flat text file. NOTE: use the "C" locale for sorting this file, as in "LC\_ALL=C sort -u -o file file".

[`-h`](#h~2)

For getting a help message.

[`-m`](#m)

Set `max-cache-size` as the maximum cache size. If the `file` is smaller than this size then the whole file will be read into memory, else the program will read blocks. Defaults to 1MB.

[`-b`](#b)

Set `block-size` as the block size for block-wise I/O. This must be a power of 2, must be no smaller than 512 and no larger than 1MB. Defaults to the `file's` filesystem's preferred blocksize.

# [EXAMPLES](#EXAMPLES)

```
$ env LC_ALL=C sort -o /tmp/words /usr/share/dict/words
$ bsearch -Kv /tmp/words day
Using whole-file method
Key day found at offset 327695 in 12 loops and 0 reads
day
$
```

# [NOTES](#NOTES)

Records must not be longer than one block's size.

Flat text files must be sorted in the "C" locale. In some systems the default locale may result in case-insensitive sorting by the sort command.

# [SEE ALSO](#SEE_ALSO)

[sort(1)](/man/os/heimdal/sort.1)

November 30, 2011 KTH-KRB

---

Document: bsearch(1) from heimdal 7.8.0-r55 (Chainguard OS)
Source: https://github.com/heimdal/heimdal
