1BSEARCH(1)                BSD General Commands Manual               BSEARCH(1)
2

NAME

4     bsearch — manages one-time passwords
5

SYNOPSIS

7     bsearch [-KVvh] [-b block-size] [-m max-cache-size] file [key ...]
8

DESCRIPTION

10     The bsearch program performs binary searches of file which must be a
11     sorted flat text file.
12
13     Each line is a record.  Each record starts with a key that is optionally
14     followed by whitespace and a value.  Whitespace may be quoted with a
15     backslash, but newline and carriage-return characters must be quoted in
16     some other manner (e.g., as backslash-n and backslash-r).  Escapes are
17     not interpreted nor removed.
18
19     If no key arguments are given on the comman-line, then keys will be read
20     from standard input.
21
22     By default only values are printed to standard output.  Use the -K option
23     to also print keys.  The exit status will be non-zero if any key lookups
24     fail.
25
26     Options are:
27
28     -K      Print keys.
29
30     -V      Don't print values.
31
32     -h      Print usage and exit.
33
34     -v      Print statistic and debug information to standard error.  file A
35             sorted flat text file.  NOTE: use the "C" locale for sorting this
36             file, as in "LC_ALL=C sort -u -o file file".
37
38     -h      For getting a help message.
39
40     -m      Set max-cache-size as the maximum cache size.  If the file is
41             smaller than this size then the whole file will be read into mem‐
42             ory, else the program will read blocks.  Defaults to 1MB.
43
44     -b      Set block-size as the block size for block-wise I/O.  This must
45             be a power of 2, must be no smaller than 512 and no larger than
46             1MB.  Defaults to the file's filesystem's preferred blocksize.
47

EXAMPLES

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

NOTES

57     Records must not be longer than one block's size.
58
59     Flat text files must be sorted in the "C" locale.  In some systems the
60     default locale may result in case-insensitive sorting by the sort com‐
61     mand.
62

SEE ALSO

64     sort(1)
65
66KTH-KRB                        November 30, 2011                       KTH-KRB
Impressum