1 '\" te
   2 .\"  Copyright (c) 1996, Sun Microsystems, Inc.  All Rights Reserved
   3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
   6 .TH BFS 1 "May 20, 1996"
   7 .SH NAME
   8 bfs \- big file scanner
   9 .SH SYNOPSIS
  10 .LP
  11 .nf
  12 \fB/usr/bin/bfs\fR [\fB-\fR] \fIfilename\fR
  13 .fi
  14 
  15 .SH DESCRIPTION
  16 .sp
  17 .LP
  18 The \fBbfs\fR command is (almost) like \fBed\fR(1) except that it is read-only
  19 and processes much larger files. Files can be up to 1024K bytes and 32K lines,
  20 with up to 512 characters, including new-line, per line (255 for 16-bit
  21 machines). \fBbfs\fR is usually more efficient than \fBed\fR(1) for scanning a
  22 file, since the file is not copied to a buffer. It is most useful for
  23 identifying sections of a large file where \fBcsplit\fR(1) can be used to
  24 divide it into more manageable pieces for editing.
  25 .sp
  26 .LP
  27 Normally, the size of the file being scanned is printed, as is the size of any
  28 file written with the \fBw\fR (write) command. The optional \fB\(mi\fR
  29 suppresses printing of sizes. Input is prompted with \fB*\fR if \fBP\fR and a
  30 carriage return are typed, as in \fBed\fR(1). Prompting can be turned off again
  31 by inputting another \fBP\fR and carriage return. Note that messages are given
  32 in response to errors if prompting is turned on.
  33 .sp
  34 .LP
  35 All address expressions described under \fBed\fR(1) are supported. In addition,
  36 regular expressions may be surrounded with two symbols besides \fB/\fR and
  37 \fB?\fR:
  38 .sp
  39 .ne 2
  40 .na
  41 \fB\fB>\fR\fR
  42 .ad
  43 .RS 5n
  44 indicates downward search without wrap-around, and
  45 .RE
  46 
  47 .sp
  48 .ne 2
  49 .na
  50 \fB\fB<\fR\fR
  51 .ad
  52 .RS 5n
  53 indicates upward search without wrap-around.
  54 .RE
  55 
  56 .sp
  57 .LP
  58 There is a slight difference in mark names; that is, only the letters \fBa\fR
  59 through \fBz\fR may be used, and all 26 marks are remembered.
  60 .SS "bfs Commands"
  61 .sp
  62 .LP
  63 The \fBe\fR, \fBg\fR, \fBv\fR, \fBk\fR, \fBp\fR, \fBq\fR, \fBw\fR, \fB=\fR,
  64 \fB!\fR, and null commands operate as described under \fBed\fR(1). Commands
  65 such as \fB\(mi\(mi\(mi\fR, \fB+++\(mi\fR, \fB+++=\fR, \fB\(mi12\fR, and
  66 \fB+4p\fR are accepted. Note that \fB1,10p\fR and \fB1,10\fR will both print
  67 the first ten lines. The \fBf\fR command only prints the name of the file being
  68 scanned; there is no  \fIremembered\fR file name. The \fB w\fR command is
  69 independent of output diversion, truncation, or crunching (see the \fBxo\fR,\fB
  70 xt\fR, and\fB xc\fR commands, below). The following additional commands are
  71 available:
  72 .sp
  73 .ne 2
  74 .na
  75 \fB\fBxf\fR\fI file\fR\fR
  76 .ad
  77 .sp .6
  78 .RS 4n
  79 Further commands are taken from the named \fBfile\fR. When an end-of-file is
  80 reached, an interrupt signal is received or an error occurs, reading resumes
  81 with the file containing the \fBxf\fR. The \fBxf\fR commands may be nested to a
  82 depth of 10.
  83 .RE
  84 
  85 .sp
  86 .ne 2
  87 .na
  88 \fB\fBxn\fR\fR
  89 .ad
  90 .sp .6
  91 .RS 4n
  92 List the marks currently in use (marks are set by the \fBk\fR command).
  93 .RE
  94 
  95 .sp
  96 .ne 2
  97 .na
  98 \fB\fBxo\fR\fI [\|file\|]\fR\fR
  99 .ad
 100 .sp .6
 101 .RS 4n
 102 Further output from the \fBp\fR and null commands is diverted to the named
 103 \fBfile\fR, which, if necessary, is created mode 666 (readable and writable by
 104 everyone), unless your \fBumask\fR setting (see \fBumask\fR(1)) dictates
 105 otherwise. If \fBfile\fR is missing, output is diverted to the standard output.
 106 Note that each diversion causes truncation or creation of the file.
 107 .RE
 108 
 109 .sp
 110 .ne 2
 111 .na
 112 \fB\fB:\fR\fI label\fR\fR
 113 .ad
 114 .sp .6
 115 .RS 4n
 116 This positions a \fIlabel\fR in a command file. The \fIlabel\fR is terminated
 117 by new-line, and blanks between the \fB:\fR (colon) and the start of the
 118 \fIlabel\fR are ignored. This command may also be used to insert comments into
 119 a command file, since labels need not be referenced.
 120 .RE
 121 
 122 .sp
 123 .ne 2
 124 .na
 125 \fB( \fB\&. \fR, \fB\&. \fR)\fBxb\fR/\fIregular expression\fR/\fIlabel\fR\fR
 126 .ad
 127 .sp .6
 128 .RS 4n
 129 A jump (either upward or downward) is made to \fIlabel\fR if the command
 130 succeeds. It fails under any of the following conditions:
 131 .RS +4
 132 .TP
 133 1.
 134 Either address is not between \fB1\fR and \fB$\fR.
 135 .RE
 136 .RS +4
 137 .TP
 138 2.
 139 The second address is less than the first.
 140 .RE
 141 .RS +4
 142 .TP
 143 3.
 144 The regular expression does not match at least one line in the specified
 145 range, including the first and last lines.
 146 .RE
 147 On success, \fB\&.\fR (dot) is set to the line matched and a jump is made to
 148 \fIlabel\fR. This command is the only one that does not issue an error message
 149 on bad addresses, so it may be used to test whether addresses are bad before
 150 other commands are executed. Note that the command, \fBxb/^/ label\fR, is an
 151 unconditional jump.
 152 .sp
 153 The \fBxb\fR command is allowed only if it is read from someplace other than a
 154 terminal. If it is read from a pipe, only a downward jump is possible.
 155 .RE
 156 
 157 .sp
 158 .ne 2
 159 .na
 160 \fB\fBxt\fR\fI number\fR\fR
 161 .ad
 162 .sp .6
 163 .RS 4n
 164 Output from the \fBp\fR and null commands is truncated to, at most,
 165 \fInumber\fR characters. The initial number is \fB255\fR.
 166 .RE
 167 
 168 .sp
 169 .ne 2
 170 .na
 171 \fB\fBxv\fR[\fIdigit\fR]\|[\fIspaces\fR]\|[\fIvalue\fR]\fR
 172 .ad
 173 .sp .6
 174 .RS 4n
 175 The variable name is the specified \fIdigit\fR following the \fBxv\fR. The
 176 commands \fBxv5100\fR or \fBxv5 100\fR both assign the value  \fB100\fR to the
 177 variable \fB5\fR. The command \fBxv61,100p\fR assigns the value \fB1,100p\fR to
 178 the variable \fB6\fR. To reference a variable, put a \fB%\fR in front of the
 179 variable name. For example, using the above assignments for variables \fB5\fR
 180 and \fB6\fR:
 181 .sp
 182 .in +2
 183 .nf
 184 1,%5p
 185 1,%5
 186 %6
 187 .fi
 188 .in -2
 189 .sp
 190 
 191 will all print the first 100 lines.
 192 .sp
 193 \fBg/%5/p\fR
 194 .sp
 195 would globally search for the characters \fB100\fR and print each line
 196 containing a match. To escape the special meaning of \fB%\fR, a \fB\e\fR must
 197 precede it.
 198 .sp
 199 \fBg/".*\e%\fR[cds]\fB/p\fR
 200 .sp
 201 could be used to match and list %c, %d, or %s formats (for example,
 202 "printf"-like statements) of characters, decimal integers, or strings. Another
 203 feature of the \fBxv\fR command is that the first line of output from a
 204 \fBUNIX\fR system command can be stored into a variable. The only requirement
 205 is that the first character of \fIvalue\fR be an \fB!\fR. For example:
 206 .sp
 207 .in +2
 208 .nf
 209 \fB\&.w junk
 210 xv5!cat junk
 211 !rm junk
 212 !echo "%5"
 213 xv6!expr %6 + 1\fR
 214 .fi
 215 .in -2
 216 .sp
 217 
 218 would put the current line into variable \fB35\fR, print it, and increment the
 219 variable \fB36\fR by one. To escape the special meaning of \fB!\fR as the first
 220 character of \fIvalue\fR, precede it with a \fB\e\fR\&.
 221 .sp
 222 \fBxv7\e!date\fR
 223 .sp
 224 stores the value \fB!date\fR into variable \fB7\fR.
 225 .RE
 226 
 227 .sp
 228 .ne 2
 229 .na
 230 \fB\fBxbz\fR\fI label\fR\fR
 231 .ad
 232 .br
 233 .na
 234 \fB\fBxbn\fR\fI label\fR\fR
 235 .ad
 236 .sp .6
 237 .RS 4n
 238 These two commands will test the last saved \fIreturn code\fR from the
 239 execution of a \fBUNIX\fR system command (\fB!\fR\fBcommand\fR) or nonzero
 240 value, respectively, to the specified label. The two examples below both
 241 search for the next five lines containing the string \fBsize\fR:
 242 .sp
 243 .ne 2
 244 .na
 245 \fBExample 1:\fR
 246 .ad
 247 .RS 14n
 248 .sp
 249 .in +2
 250 .nf
 251 \fBxv55
 252 : l
 253 /size/
 254 xv5!expr %5 \(mi 1
 255 !if 0%5 != 0 exit 2
 256 xbn l\fR
 257 .fi
 258 .in -2
 259 .sp
 260 
 261 .RE
 262 
 263 .sp
 264 .ne 2
 265 .na
 266 \fBExample 2:\fR
 267 .ad
 268 .RS 14n
 269 .sp
 270 .in +2
 271 .nf
 272 \fBxv45
 273 : l
 274 /size/
 275 xv4!expr %4 \(mi 1
 276 !if 0%4 = 0 exit 2
 277 xbz l\fR
 278 .fi
 279 .in -2
 280 .sp
 281 
 282 .RE
 283 
 284 .RE
 285 
 286 .sp
 287 .ne 2
 288 .na
 289 \fB\fBxc\fR [\fBswitch\fR]\fR
 290 .ad
 291 .sp .6
 292 .RS 4n
 293 If \fBswitch\fR is \fB1\fR, output from the \fBp\fR and null commands is
 294 crunched; if \fBswitch\fR is \fB0\fR, it is not. Without an argument, \fBxc\fR
 295 reverses \fBswitch\fR. Initially, \fBswitch\fR is set for no crunching.
 296 Crunched output has strings of tabs and blanks reduced to one blank and blank
 297 lines suppressed.
 298 .RE
 299 
 300 .SH OPERANDS
 301 .sp
 302 .LP
 303 The following operand is supported:
 304 .sp
 305 .ne 2
 306 .na
 307 \fB\fIfilename\fR\fR
 308 .ad
 309 .RS 12n
 310 Any file up to 1024K bytes and 32K lines, with up to 512 characters, including
 311 new-line, per line (255 for 16-bit machines). \fIfilename\fR can be a section
 312 of a larger file which has been divided into more manageable sections for
 313 editing by the use of \fBcsplit\fR(1).
 314 .RE
 315 
 316 .SH EXIT STATUS
 317 .sp
 318 .LP
 319 The following exit values are returned:
 320 .sp
 321 .ne 2
 322 .na
 323 \fB\fB0\fR\fR
 324 .ad
 325 .RS 6n
 326 Successful completion without any file or command errors.
 327 .RE
 328 
 329 .sp
 330 .ne 2
 331 .na
 332 \fB\fB>0\fR\fR
 333 .ad
 334 .RS 6n
 335 An error occurred.
 336 .RE
 337 
 338 .SH SEE ALSO
 339 .sp
 340 .LP
 341 \fBcsplit\fR(1), \fBed\fR(1), \fBumask\fR(1), \fBattributes\fR(5)
 342 .SH DIAGNOSTICS
 343 .sp
 344 .LP
 345 Message is \fB?\fR for errors in commands, if prompting is turned off.
 346 Self-explanatory error messages are displayed when prompting is on.