sdb.1 (6941B)
1 .TH SDB 1 2 .SH NAME 3 sdbquery, sdbedit, sdbjoin, sdbmap, sdbpretty, sdbrval, sdbuniq \- simple database 4 .SH SYNOPSIS 5 .B sdbquery 6 [ 7 .B -f 8 .I file 9 ] 10 .I "attr value" 11 [ 12 .I "attr value" 13 ] 14 \&... 15 .br 16 .B sdbedit 17 [ 18 .B -f 19 .I file 20 ] 21 .I "attr value" 22 [ 23 .I "attr value" 24 ] 25 \&... 26 .br 27 .B sdbjoin 28 [ 29 .B -f 30 .I file0 31 ] 32 .I file1 33 [ 34 .I "attr value" 35 ] 36 \&... 37 .br 38 .B sdbmap 39 [ 40 .B -k 41 .I attr 42 ] 43 [ 44 .B -f 45 .I file0 46 ] 47 .I mapfile 48 .I source-attr 49 .I dest-attr 50 .br 51 .B sdbpretty 52 [ 53 .B -f 54 .I file 55 ] 56 .br 57 .B sdbrval 58 [ 59 .B -amt 60 ] 61 .I attr 62 \&... 63 .br 64 .B sdbuniq 65 [ 66 .B -f 67 .I file 68 ] 69 [ 70 .I attr 71 ] 72 \&... 73 .SH DESCRIPTION 74 These commands operate on simple databases using the same format as Plan 9's 75 network database (ndb). 76 Database files contain records with attribute=value pairs, 77 with records separated by blank lines and 78 continuation lines starting with whitespace. 79 Comments begin with '#'. 80 .PP 81 .I Sdbquery 82 searches the database for records matching the given attribute-value pairs. 83 With 84 .BR -f , 85 it reads from the specified 86 .IR file ; 87 otherwise it reads from standard input. 88 All records matching the query are printed. 89 .PP 90 .I Sdbedit 91 finds records matching the first attribute-value pair (the query) 92 and adds or updates them with the remaining attribute-value pairs (the edits). 93 If no matching record is found, it creates a new record. 94 With 95 .BR -f , 96 it reads from the specified 97 .IR file ; 98 otherwise it reads from standard input. 99 The updated database is written to standard output. 100 .PP 101 .I Sdbjoin 102 performs a database join operation between two files. 103 For each record in 104 .I file0 105 (or standard input if 106 .B -f 107 is not given), 108 it uses the record's first attribute-value pair as a query to find matching records in 109 .IR file1 . 110 Records from 111 .I file1 112 that contain the queried attribute-value pair are joined with the 113 .I file0 114 record. 115 Additional attribute-value constraints can be specified. 116 The joined records are written to standard output. 117 .PP 118 .I Sdbmap 119 uses a mapping database 120 .I mapfile 121 to transform values in the input database. 122 It looks up values of 123 .I source-attr 124 in the mapping database and replaces them with the corresponding 125 .I dest-attr 126 values. 127 With 128 .BR -k , 129 it uses 130 .I attr 131 as the key attribute in the mapping database; 132 otherwise it uses 133 .IR source-attr . 134 With 135 .BR -f , 136 it reads from the specified 137 .IR file0 ; 138 otherwise it reads from standard input. 139 .PP 140 .I Sdbpretty 141 formats database records for display, printing each record with 142 the first attribute on its own line and subsequent attributes indented. 143 With 144 .BR -f , 145 it reads from the specified 146 .IR file ; 147 otherwise it reads from standard input. 148 .PP 149 .I Sdbrval 150 extracts specified attribute values from database records. 151 With 152 .BR -a , 153 it prints attribute names and values in the form 154 .BR attr=value . 155 With 156 .BR -m , 157 it uses pattern matching to select attributes. 158 With 159 .BR -t , 160 it uses minimal escaping that only handles essential 161 tab-separated format requirements (escaping tabs, newlines, and 162 backslashes) rather than full SDB format escaping. 163 It reads from standard input and prints tab-separated values for each record. 164 .PP 165 .I Sdbuniq 166 removes duplicate records based on specified key attributes. 167 Input must be sorted by the first attribute and key attributes for correct operation. 168 Records are considered duplicates if they have the same value for the first attribute 169 and the same values for all specified key attributes. 170 When duplicates are found, it merges their attributes and prints the combined record. 171 Only records with more than one attribute beyond the specified keys are output. 172 With 173 .BR -f , 174 it reads from the specified 175 .IR file ; 176 otherwise it reads from standard input. 177 .SH EXAMPLES 178 Create a starship database: 179 .IP 180 .EX 181 % cat >ships.db 182 ship=enterprise class=constitution captain=kirk 183 crew=430 warp=8 phasers=12 torpedoes=6 184 185 ship=defiant class=defiant captain=sisko 186 crew=50 warp=9.5 cloak=yes quantum=40 187 188 ship=voyager class=intrepid captain=janeway 189 crew=150 warp=9.975 bioneural=yes delta=far 190 .EE 191 .PP 192 Find warp-capable ships commanded by captains named 'k*': 193 .IP 194 .EX 195 % sdbquery -f ships.db captain 'k*' 196 ship=enterprise class=constitution captain=kirk 197 crew=430 warp=8 phasers=12 torpedoes=6 198 .EE 199 .PP 200 Transfer command and update crew complement: 201 .IP 202 .EX 203 % sdbquery -f ships.db ship voyager | 204 sdbedit ship voyager captain chakotay crew 147 205 ship=voyager class=intrepid captain=chakotay 206 crew=147 warp=9.975 bioneural=yes delta=far 207 .EE 208 .PP 209 Create quantum torpedo inventory and map to ships: 210 .IP 211 .EX 212 % cat >weapons.db 213 quantum=40 type=photon power=high 214 federation=yes klingon=no 215 216 quantum=6 type=phaser power=medium 217 federation=yes cardassian=yes 218 % sdbquery -f ships.db quantum '*' | 219 sdbmap weapons.db quantum type 220 ship=defiant class=defiant captain=sisko 221 crew=50 warp=9.5 cloak=yes type=photon 222 .EE 223 .PP 224 Analyze fleet capabilities by extracting warp factors: 225 .IP 226 .EX 227 % sdbquery -f ships.db ship '*' | sdbrval -a warp | sort -t= -k2 -n 228 warp=8 229 warp=9.5 230 warp=9.975 231 .EE 232 .PP 233 Join ship records with their class specifications: 234 .IP 235 .EX 236 % cat >classes.db 237 ship=enterprise registry=NCC-1701 commissioned=2245 238 designer=cochrane yards=sf-fleet 239 240 ship=defiant registry=NX-74205 commissioned=2366 241 designer=sisko yards=utopia-planitia 242 243 ship=voyager registry=NCC-74656 commissioned=2371 244 designer=janeway yards=utopia-planitia 245 % sdbjoin -f ships.db classes.db 246 ship=enterprise class=constitution captain=kirk 247 crew=430 warp=8 phasers=12 torpedoes=6 248 registry=NCC-1701 commissioned=2245 249 designer=cochrane yards=sf-fleet 250 ship=defiant class=defiant captain=sisko 251 crew=50 warp=9.5 cloak=yes quantum=40 252 registry=NX-74205 commissioned=2366 253 designer=sisko yards=utopia-planitia 254 ship=voyager class=intrepid captain=janeway 255 crew=150 warp=9.975 bioneural=yes delta=far 256 registry=NCC-74656 commissioned=2371 257 designer=janeway yards=utopia-planitia 258 .EE 259 .PP 260 Monitor temporal anomalies with duplicate detection: 261 .IP 262 .EX 263 % cat >timeline.db 264 ship=enterprise date=2267 incident=mirror_universe 265 spock=bearded kirk=evil 266 267 ship=enterprise date=2267 incident=mirror_universe 268 mccoy=savage uhura=rebel 269 270 ship=defiant date=2375 incident=mirror_universe 271 sisko=terran kira=intendant odo=security 272 % sdbuniq -f timeline.db date incident 273 ship=enterprise date=2267 incident=mirror_universe 274 spock=bearded kirk=evil mccoy=savage 275 uhura=rebel 276 ship=defiant date=2375 incident=mirror_universe 277 sisko=terran kira=intendant odo=security 278 .EE 279 .PP 280 Format fleet status for admiralty briefing: 281 .IP 282 .EX 283 % sdbpretty <ships.db 284 ship=enterprise 285 class=constitution 286 captain=kirk 287 crew=430 288 warp=8 289 phasers=12 290 torpedoes=6 291 ship=defiant 292 class=defiant 293 captain=sisko 294 crew=50 295 warp=9.5 296 cloak=yes 297 quantum=40 298 .EE 299 .SH SOURCE 300 .B \*9/src/cmd/sdb 301 .SH SEE ALSO 302 .MR ndb (1) , 303 .MR ndb (3) , 304 .MR ndb (7) , 305 .MR sdb (3) , 306 .MR sdbr (3)