1bfs(1)                           User Commands                          bfs(1)
2
3
4

NAME

6       bfs - big file scanner
7

SYNOPSIS

9       /usr/bin/bfs [-] filename
10
11

DESCRIPTION

13       The  bfs command is (almost) like ed(1) except that it is read-only and
14       processes much larger files. Files can be up to  1024K  bytes  and  32K
15       lines, with up to 512 characters, including new-line, per line (255 for
16       16-bit machines). bfs is usually more efficient than ed(1) for scanning
17       a file, since the file is not copied to a buffer. It is most useful for
18       identifying sections of a large file where csplit(1)  can  be  used  to
19       divide it into more manageable pieces for editing.
20
21
22       Normally, the size of the file being scanned is printed, as is the size
23       of any file written with the w (write) command.  The  optional  sup‐
24       presses printing of sizes. Input is prompted with * if P and a carriage
25       return are typed, as in ed(1). Prompting can be  turned  off  again  by
26       inputting  another  P and carriage return. Note that messages are given
27       in response to errors if prompting is turned on.
28
29
30       All address expressions described under ed(1) are supported.  In  addi‐
31       tion,  regular expressions may be surrounded with two symbols besides /
32       and ?:
33
34       >    indicates downward search without wrap-around, and
35
36
37       <    indicates upward search without wrap-around.
38
39
40
41       There is a slight difference in mark names; that is, only the letters a
42       through z may be used, and all 26 marks are remembered.
43
44   bfs Commands
45       The  e,  g, v, k, p, q, w, =, !, and null commands operate as described
46       under ed(1). Commands such  as  −−−,  +++−,  +++=,  −12,  and  +4p  are
47       accepted.  Note  that  1,10p  and  1,10  will both print  the first ten
48       lines. The f command only prints the name of the  file  being  scanned;
49       there  is  no   remembered  file name. The  w command is independent of
50       output diversion, truncation, or crunching (see the xo, xt, and xc com‐
51       mands, below). The following additional commands are available:
52
53       xf file
54
55           Further commands are taken from the named file. When an end-of-file
56           is reached, an interrupt signal is received  or  an  error  occurs,
57           reading  resumes  with  the file containing the xf. The xf commands
58           may be nested to a depth of 10.
59
60
61       xn
62
63           List the marks currently in use (marks are set by the k command).
64
65
66       xo [file]
67
68           Further output from the p and null  commands  is  diverted  to  the
69           named  file, which, if necessary, is created mode 666 (readable and
70           writable by everyone), unless your  umask  setting  (see  umask(1))
71           dictates  otherwise.  If file is missing, output is diverted to the
72           standard output. Note that each diversion causes truncation or cre‐
73           ation of the file.
74
75
76       : label
77
78           This  positions  a label in a command file. The label is terminated
79           by new-line, and blanks between the : (colon) and the start of  the
80           label are ignored. This command may also be used to insert comments
81           into a command file, since labels need not be referenced.
82
83
84       ( . , . )xb/regular expression/label
85
86           A jump (either upward or downward) is made to label if the  command
87           succeeds. It fails under any of the following conditions:
88
89               1.     Either address is not between 1 and $.
90
91               2.     The second address is less than the first.
92
93               3.     The  regular expression does not match at least one line
94                      in the specified range, including  the  first  and  last
95                      lines.
96           On  success,  . (dot) is set to the line matched and a jump is made
97           to label. This command is the only one that does not issue an error
98           message  on  bad  addresses,  so  it  may  be  used to test whether
99           addresses are bad before other commands are executed. Note that the
100           command, xb/^/ label, is an unconditional jump.
101
102           The  xb  command is allowed only if it is read from someplace other
103           than a terminal. If it is read from a pipe, only a downward jump is
104           possible.
105
106
107       xt number
108
109           Output  from the p and null commands is truncated to, at most, num‐
110           ber characters. The initial number is 255.
111
112
113       xv[digit][spaces][value]
114
115           The variable name is the specified digit following the xv. The com‐
116           mands  xv5100 or xv5 100 both assign the value  100 to the variable
117           5. The command xv61,100p assigns the value 1,100p to  the  variable
118           6.  To reference a variable, put a % in front of the variable name.
119           For example, using the above assignments for variables 5 and 6:
120
121             1,%5p
122             1,%5
123             %6
124
125
126           will all print the first 100 lines.
127
128           g/%5/p
129
130           would globally search for the characters 100 and  print  each  line
131           containing  a  match.  To escape the special meaning of %, a \ must
132           precede it.
133
134           g/".*\%[cds]/p
135
136           could be used to match and list %c, %d, or %s formats (for example,
137           "printf"-like  statements)  of  characters,  decimal  integers,  or
138           strings. Another feature of the xv command is that the  first  line
139           of output from a UNIX system command can be stored into a variable.
140           The only requirement is that the first character of value be an  !.
141           For example:
142
143             .w junk
144             xv5!cat junk
145             !rm junk
146             !echo "%5"
147             xv6!expr %6 + 1
148
149
150           would  put  the current line into variable 35, print it, and incre‐
151           ment the variable 36 by one. To escape the special meaning of !  as
152           the first character of value, precede it with a \.
153
154           xv7\!date
155
156           stores the value !date into variable 7.
157
158
159       xbz label
160       xbn label
161
162           These  two  commands  will test the last saved return code from the
163           execution of a UNIX system command  (!command)  or  nonzero  value,
164           respectively,  to  the specified label. The two examples below both
165           search for the next five lines containing the string size:
166
167           Example 1:
168                           xv55
169                           : l
170                           /size/
171                           xv5!expr %5 − 1
172                           !if 0%5 != 0 exit 2
173                           xbn l
174
175
176
177
178           Example 2:
179                           xv45
180                           : l
181                           /size/
182                           xv4!expr %4 − 1
183                           !if 0%4 = 0 exit 2
184                           xbz l
185
186
187
188
189
190       xc [switch]
191
192           If switch is 1, output from the p and null commands is crunched; if
193           switch  is  0,  it is not. Without an argument, xc reverses switch.
194           Initially, switch is set for  no  crunching.  Crunched  output  has
195           strings  of  tabs  and  blanks reduced to one blank and blank lines
196           suppressed.
197
198

OPERANDS

200       The following operand is supported:
201
202       filename    Any file up to 1024K bytes and 32K lines, with  up  to  512
203                   characters,  including  new-line,  per line (255 for 16-bit
204                   machines). filename can be a section of a larger file which
205                   has  been divided into more manageable sections for editing
206                   by the use of csplit(1).
207
208

EXIT STATUS

210       The following exit values are returned:
211
212       0     Successful completion without any file or command errors.
213
214
215       >0    An error occurred.
216
217

ATTRIBUTES

219       See attributes(5) for descriptions of the following attributes:
220
221
222
223
224       ┌─────────────────────────────┬─────────────────────────────┐
225       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
226       ├─────────────────────────────┼─────────────────────────────┤
227       │Availability                 │SUNWesu                      │
228       └─────────────────────────────┴─────────────────────────────┘
229

SEE ALSO

231       csplit(1), ed(1), umask(1), attributes(5)
232

DIAGNOSTICS

234       Message is ? for errors in commands, if prompting is turned off.  Self-
235       explanatory error messages are displayed when prompting is on.
236
237
238
239SunOS 5.11                        20 May 1996                           bfs(1)
Impressum