1.\" $NetBSD: db.1,v 1.17 2005/06/20 02:53:38 lukem Exp $ 2.\" 3.\" Copyright (c) 2002-2005 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Luke Mewburn of Wasabi Systems. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd June 20, 2005 38.Dt DB 1 39.Os 40. 41.Sh NAME 42.Nm db 43.Nd 44manipulate 45.Xr db 3 Ns 's 46.Xr btree 3 47and 48.Xr hash 3 49databases 50. 51.Sh SYNOPSIS 52.Nm 53.Op Fl KiNqV 54.Bk -words 55.Op Fl E Ar endian 56.Ek 57.Bk -words 58.Op Fl f Ar infile 59.Ek 60.Bk -words 61.Op Fl O Ar outsep 62.Ek 63.Bk -words 64.Op Fl S Ar visitem 65.Ek 66.Bk -words 67.Op Fl T Ar visspec 68.Ek 69.Bk -words 70.Op Fl X Ar extravis 71.Ek 72.Ar type 73.Ar dbfile 74.Bk -words 75.Op Ar key Op Ar \&.\&.\&. 76.Ek 77. 78.Nm 79.Fl d 80.Op Fl iNq 81.Bk -words 82.Op Fl E Ar endian 83.Ek 84.Bk -words 85.Op Fl f Ar infile 86.Ek 87.Bk -words 88.Op Fl U Ar unvisitem 89.Ek 90.Ar type 91.Ar dbfile 92.Bk -words 93.Op Ar key Op Ar \&.\&.\&. 94.Ek 95. 96.Nm 97.Fl w 98.Op Fl CDiNqR 99.Bk -words 100.Op Fl E Ar endian 101.Ek 102.Bk -words 103.Op Fl F Ar insep 104.Ek 105.Bk -words 106.Op Fl f Ar infile 107.Ek 108.Bk -words 109.Op Fl m Ar mode 110.Ek 111.Bk -words 112.Op Fl U Ar unvisitem 113.Ek 114.Ar type 115.Ar dbfile 116.Bk -words 117.Op Ar key Ar value Op Ar \&.\&.\&. 118.Ek 119. 120.Sh DESCRIPTION 121.Nm 122allows manipulation of 123.Xr btree 3 124and 125.Xr hash 3 126.Pq Xr db 3 127databases. 128.Pp 129.Nm 130has three modes of operation to perform upon 131.Ar dbfile : 132.Bl -tag -width "delete" -offset indent 133.It read 134Displays the given 135.Ar key Ns s , 136and keys described in 137.Ar infile . 138If no keys and no 139.Ar infile 140is specified, the entire database is displayed. 141This is the default mode of operation. 142.It delete 143Enabled with 144.Fl d . 145Deletes the given 146.Ar key Ns s , 147and keys described in 148.Ar infile . 149.It write 150Enabled with 151.Fl w . 152Writes the given 153.Ar key Ns s 154and 155.Ar value Ns s , 156and keys and values described in 157.Ar infile 158(in the latter case, entries are separated by 159.Ar insep ) . 160.El 161.Pp 162There are two mandatory arguments: 163.Ar type 164is the database type; either 165.Sq Sy btree 166or 167.Sq Sy hash , 168and 169.Ar dbfile 170is the database file to manipulate. 171.Pp 172Options valid for all modes are: 173.Bl -tag -width Fl -offset indent 174. 175.It Fl E Ar endian 176Set the endianness of the database. 177.Ar endian 178may be one of: 179.Bl -tag -width 1n -offset indent -compact 180.It Sy B 181Big endian 182.It Sy H 183Host endian 184.It Sy L 185Little endian 186.El 187Defaults to 188.Sq H 189(host endian). 190. 191.It Fl f Ar infile 192Contains a list of keys 193(for read and delete), or 194.Ar insep 195separated keys and values (for write) 196to be used as arguments to the given mode. 197If 198.Ar infile 199is 200.Sq Sy - , 201.Dv stdin 202is used. 203. 204.It Fl i 205Keys are converted to lower case before manipulation. 206. 207.It Fl N 208Do not include the NUL byte at the end of the key or value. 209. 210.It Fl q 211Quiet operation. 212In read mode, missing keys are not considered to be an error. 213In delete 214.Pq Fl d 215and write 216.Pq Fl w 217modes, 218the result of various operations is suppressed. 219. 220.El 221. 222.Pp 223Read mode specific options are: 224. 225.Bl -tag -width Fl -offset indent 226.It Fl K 227Display key. 228. 229.It Fl O Ar outsep 230Field separator string between key and value. 231Defaults to a single tab 232.Pq Sq \et . 233. 234.It Fl S Ar visitem 235Specify items to 236.Xr strvis 3 237encode. 238The 239.Ar visitem 240option-argument is a character specifying if the key 241.Pq Ar k , 242the value 243.Pq Ar v 244or both 245.Pq Ar b 246should be encoded. 247. 248.It Fl T Ar visspec 249Control how the items specified by the 250.Fl S 251option are encoded. 252The 253.Ar visspec 254option-argument is a string specifying 255.Xr strvis 3 256options. 257The string consists of the specification characters 258.Cm b , c , o , 259.Cm s , t , 260and 261.Cm w . 262See 263.Xr vis 1 Ns 's 264corresponding options for the meaning of these characters. 265. 266.It Fl V 267Display value. 268. 269.It Fl X Ar extravis 270When encoding items with 271.Fl S 272option also encode characters in 273.Ar extravis , 274per 275.Xr svis 3 . 276. 277.El 278.Pp 279.Bd -ragged -offset indent 280(If neither of 281.Fl K 282or 283.Fl V 284is given, both options are enabled.) 285.Ed 286. 287.Pp 288Write mode specific options are: 289.Bl -tag -width Fl -offset indent 290. 291.It Fl C 292Create new database, and truncate existing databases. 293. 294.It Fl D 295Allow duplicate entries. 296(Requires 297.Fl R 298to be useful.) 299. 300.It Fl F Ar insep 301Input field separator string between key and value used when parsing 302.Ar infile . 303Defaults to a single space 304.Pq Sq \ . 305. 306.It Fl m Ar mode 307Octal mode of created database. 308Defaults to 309.Sq 0644 . 310. 311.It Fl R 312Overwrite existing entries. 313If not specified, writing to an existing entry raises an error. 314. 315.El 316.Pp 317Write and delete mode specific options are: 318.Bl -tag -width Fl -offset indent 319. 320.It Fl U Ar unvisitem 321Specify items to 322.Xr strunvis 3 323decode. 324The 325.Ar unvisitem 326option-argument is a character specifying if the key 327.Pq Ar k , 328the value 329.Pq Ar v 330or both 331.Pq Ar b 332should be decoded. 333. 334.El 335. 336.Sh SEE ALSO 337.Xr vis 1 , 338.Xr btree 3 , 339.Xr db 3 , 340.Xr hash 3 , 341.Xr strunvis 3 , 342.Xr strvis 3 , 343.Xr svis 3 , 344.Xr makemap 8 345. 346.Sh HISTORY 347The 348.Nm 349command appeared in 350.Nx 2.0 . 351. 352.Sh AUTHORS 353.An Luke Mewburn 354.Aq lukem@NetBSD.org . 355