summaryrefslogtreecommitdiff
path: root/usr/src/man/man1/bfs.1
blob: ddfece0fc040bffc3ad3b1786a7b4e990b588938 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
'\" te
.\"  Copyright (c) 1996, Sun Microsystems, Inc.  All Rights Reserved
.\" 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.
.\" 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.
.\" 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]
.TH bfs 1 "20 May 1996" "SunOS 5.11" "User Commands"
.SH NAME
bfs \- big file scanner
.SH SYNOPSIS
.LP
.nf
\fB/usr/bin/bfs\fR [\fB-\fR] \fIfilename\fR
.fi

.SH DESCRIPTION
.sp
.LP
The \fBbfs\fR command is (almost) like \fBed\fR(1) except that it is read-only
and processes much larger files. Files can be up to 1024K bytes and 32K lines,
with up to 512 characters, including new-line, per line (255 for 16-bit
machines). \fBbfs\fR is usually more efficient than \fBed\fR(1) for scanning a
file, since the file is not copied to a buffer. It is most useful for
identifying sections of a large file where \fBcsplit\fR(1) can be used to
divide it into more manageable pieces for editing.
.sp
.LP
Normally, the size of the file being scanned is printed, as is the size of any
file written with the \fBw\fR (write) command. The optional \fB\(mi\fR
suppresses printing of sizes. Input is prompted with \fB*\fR if \fBP\fR and a
carriage return are typed, as in \fBed\fR(1). Prompting can be turned off again
by inputting another \fBP\fR and carriage return. Note that messages are given
in response to errors if prompting is turned on.
.sp
.LP
All address expressions described under \fBed\fR(1) are supported. In addition,
regular expressions may be surrounded with two symbols besides \fB/\fR and
\fB?\fR:
.sp
.ne 2
.mk
.na
\fB\fB>\fR\fR
.ad
.RS 5n
.rt  
indicates downward search without wrap-around, and
.RE

.sp
.ne 2
.mk
.na
\fB\fB<\fR\fR
.ad
.RS 5n
.rt  
indicates upward search without wrap-around.
.RE

.sp
.LP
There is a slight difference in mark names; that is, only the letters \fBa\fR
through \fBz\fR may be used, and all 26 marks are remembered.
.SS "bfs Commands"
.sp
.LP
The \fBe\fR, \fBg\fR, \fBv\fR, \fBk\fR, \fBp\fR, \fBq\fR, \fBw\fR, \fB=\fR,
\fB!\fR, and null commands operate as described under \fBed\fR(1). Commands
such as \fB\(mi\(mi\(mi\fR, \fB+++\(mi\fR, \fB+++=\fR, \fB\(mi12\fR, and
\fB+4p\fR are accepted. Note that \fB1,10p\fR and \fB1,10\fR will both print
the first ten lines. The \fBf\fR command only prints the name of the file being
scanned; there is no  \fIremembered\fR file name. The \fB w\fR command is
independent of output diversion, truncation, or crunching (see the \fBxo\fR,\fB
xt\fR, and\fB xc\fR commands, below). The following additional commands are
available:
.sp
.ne 2
.mk
.na
\fB\fBxf\fR\fI file\fR\fR
.ad
.sp .6
.RS 4n
Further commands are taken from the named \fBfile\fR. When an end-of-file is
reached, an interrupt signal is received or an error occurs, reading resumes
with the file containing the \fBxf\fR. The \fBxf\fR commands may be nested to a
depth of 10.
.RE

.sp
.ne 2
.mk
.na
\fB\fBxn\fR\fR
.ad
.sp .6
.RS 4n
List the marks currently in use (marks are set by the \fBk\fR command).
.RE

.sp
.ne 2
.mk
.na
\fB\fBxo\fR\fI [\|file\|]\fR\fR
.ad
.sp .6
.RS 4n
Further output from the \fBp\fR and null commands is diverted to the named
\fBfile\fR, which, if necessary, is created mode 666 (readable and writable by
everyone), unless your \fBumask\fR setting (see \fBumask\fR(1)) dictates
otherwise. If \fBfile\fR is missing, output is diverted to the standard output.
Note that each diversion causes truncation or creation of the file.
.RE

.sp
.ne 2
.mk
.na
\fB\fB:\fR\fI label\fR\fR
.ad
.sp .6
.RS 4n
This positions a \fIlabel\fR in a command file. The \fIlabel\fR is terminated
by new-line, and blanks between the \fB:\fR (colon) and the start of the
\fIlabel\fR are ignored. This command may also be used to insert comments into
a command file, since labels need not be referenced.
.RE

.sp
.ne 2
.mk
.na
\fB( \fB\&. \fR, \fB\&. \fR)\fBxb\fR/\fIregular expression\fR/\fIlabel\fR\fR
.ad
.sp .6
.RS 4n
A jump (either upward or downward) is made to \fIlabel\fR if the command
succeeds. It fails under any of the following conditions:
.RS +4
.TP
1.
Either address is not between \fB1\fR and \fB$\fR.
.RE
.RS +4
.TP
2.
The second address is less than the first.
.RE
.RS +4
.TP
3.
The regular expression does not match at least one line in the specified
range, including the first and last lines.
.RE
On success, \fB\&.\fR (dot) is set to the line matched and a jump is made to
\fIlabel\fR. This command is the only one that does not issue an error message
on bad addresses, so it may be used to test whether addresses are bad before
other commands are executed. Note that the command, \fBxb/^/ label\fR, is an
unconditional jump.
.sp
The \fBxb\fR command is allowed only if it is read from someplace other than a
terminal. If it is read from a pipe, only a downward jump is possible.
.RE

.sp
.ne 2
.mk
.na
\fB\fBxt\fR\fI number\fR\fR
.ad
.sp .6
.RS 4n
Output from the \fBp\fR and null commands is truncated to, at most,
\fInumber\fR characters. The initial number is \fB255\fR.
.RE

.sp
.ne 2
.mk
.na
\fB\fBxv\fR[\fIdigit\fR]\|[\fIspaces\fR]\|[\fIvalue\fR]\fR
.ad
.sp .6
.RS 4n
The variable name is the specified \fIdigit\fR following the \fBxv\fR. The
commands \fBxv5100\fR or \fBxv5 100\fR both assign the value  \fB100\fR to the
variable \fB5\fR. The command \fBxv61,100p\fR assigns the value \fB1,100p\fR to
the variable \fB6\fR. To reference a variable, put a \fB%\fR in front of the
variable name. For example, using the above assignments for variables \fB5\fR
and \fB6\fR:
.sp
.in +2
.nf
1,%5p
1,%5
%6
.fi
.in -2
.sp

will all print the first 100 lines.
.sp
\fBg/%5/p\fR
.sp
would globally search for the characters \fB100\fR and print each line
containing a match. To escape the special meaning of \fB%\fR, a \fB\e\fR must
precede it.
.sp
\fBg/".*\e%\fR[cds]\fB/p\fR
.sp
could be used to match and list %c, %d, or %s formats (for example,
"printf"-like statements) of characters, decimal integers, or strings. Another
feature of the \fBxv\fR command is that the first line of output from a
\fBUNIX\fR system command can be stored into a variable. The only requirement
is that the first character of \fIvalue\fR be an \fB!\fR. For example:
.sp
.in +2
.nf
\fB\&.w junk
xv5!cat junk
!rm junk
!echo "%5"
xv6!expr %6 + 1\fR
.fi
.in -2
.sp

would put the current line into variable \fB35\fR, print it, and increment the
variable \fB36\fR by one. To escape the special meaning of \fB!\fR as the first
character of \fIvalue\fR, precede it with a \fB\e\fR\&.
.sp
\fBxv7\e!date\fR
.sp
stores the value \fB!date\fR into variable \fB7\fR.
.RE

.sp
.ne 2
.mk
.na
\fB\fBxbz\fR\fI label\fR\fR
.ad
.br
.na
\fB\fBxbn\fR\fI label\fR\fR
.ad
.sp .6
.RS 4n
These two commands will test the last saved \fIreturn code\fR from the
execution of a \fBUNIX\fR system command (\fB!\fR\fBcommand\fR) or nonzero
value, respectively, to the specified label. The two examples below both
search for the next five lines containing the string \fBsize\fR:
.sp
.ne 2
.mk
.na
\fBExample 1:\fR
.ad
.RS 14n
.rt  
.sp
.in +2
.nf
\fBxv55
: l
/size/
xv5!expr %5 \(mi 1
!if 0%5 != 0 exit 2
xbn l\fR
.fi
.in -2
.sp

.RE

.sp
.ne 2
.mk
.na
\fBExample 2:\fR
.ad
.RS 14n
.rt  
.sp
.in +2
.nf
\fBxv45
: l
/size/
xv4!expr %4 \(mi 1
!if 0%4 = 0 exit 2
xbz l\fR
.fi
.in -2
.sp

.RE

.RE

.sp
.ne 2
.mk
.na
\fB\fBxc\fR [\fBswitch\fR]\fR
.ad
.sp .6
.RS 4n
If \fBswitch\fR is \fB1\fR, output from the \fBp\fR and null commands is
crunched; if \fBswitch\fR is \fB0\fR, it is not. Without an argument, \fBxc\fR
reverses \fBswitch\fR. Initially, \fBswitch\fR is set for no crunching.
Crunched output has strings of tabs and blanks reduced to one blank and blank
lines suppressed.
.RE

.SH OPERANDS
.sp
.LP
The following operand is supported:
.sp
.ne 2
.mk
.na
\fB\fIfilename\fR\fR
.ad
.RS 12n
.rt  
Any file up to 1024K bytes and 32K lines, with up to 512 characters, including
new-line, per line (255 for 16-bit machines). \fIfilename\fR can be a section
of a larger file which has been divided into more manageable sections for
editing by the use of \fBcsplit\fR(1).
.RE

.SH EXIT STATUS
.sp
.LP
The following exit values are returned:
.sp
.ne 2
.mk
.na
\fB\fB0\fR\fR
.ad
.RS 6n
.rt  
Successful completion without any file or command errors.
.RE

.sp
.ne 2
.mk
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
.rt  
An error occurred.
.RE

.SH SEE ALSO
.sp
.LP
\fBcsplit\fR(1), \fBed\fR(1), \fBumask\fR(1), \fBattributes\fR(5)
.SH DIAGNOSTICS
.sp
.LP
Message is \fB?\fR for errors in commands, if prompting is turned off.
Self-explanatory error messages are displayed when prompting is on.