bfs(1) bfs(1)
NAME
bfs - big file scanner
SYNOPSIS
bfs [-] file
DESCRIPTION
The bfs command is similar to ed 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 bytes, including new-line,
per line (255 for 16-bit machines). bfs is usually more
efficient than ed 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 the csplit command can be used
to divide it into more manageable pieces for editing.
bfs processes supplementary code set characters in file, and
recognizes supplementary code set characters in the labels
given to the :, xb, xbn, and xbz commands (see below)
according to the locale specified in the LC_CTYPE environment
variable [see LANG on environ(5)]. In regular expressions,
pattern searches are performed on characters, not bytes [see
ed(1)].
Normally, the size in bytes of the file being scanned is
printed, as is the size of any file written with the w
command. The optional - suppresses printing of sizes. Input
is prompted with * if P and a RETURN are typed, as in ed.
Prompting can be turned off again by inputting another P and
RETURN. Messages are given in response to errors if prompting
is turned on.
All address expressions described under ed are supported. In
addition, regular expressions may be surrounded with two
symbols besides / and ?: > indicates downward search without
wrap-around, and < indicates upward search without wrap-
around.
The e, g, v, k, p, q, w, =, ! and null commands operate as
described under ed. Commands such as ---, +++-, +++=, -12,
and +4p are accepted. Note that 1,10p and 1,10 both print the
first ten lines. The f command only prints the name of the
file being scanned; there is no remembered file name. The w
command is independent of output diversion, truncation, or
crunching (see the xo, xt, and xc commands, below). The
following additional commands are available:
Copyright 1994 Novell, Inc. Page 1
bfs(1) bfs(1)
xf file
Further commands are taken from the named file. When an
end-of-file is reached, an interrupt signal is received
or an error occurs, reading resumes with the file
containing the xf. The xf commands may be nested to a
depth of 10.
xn List the marks currently in use (marks are set by the k
command).
xo [file]
Further output from the p and null commands is diverted
to the named file, which, if necessary, is created with
mode 666 (readable and writable by everyone), unless
your umask setting dictates otherwise; see umask(1). If
file is missing, output is diverted to the standard
output. Note that each diversion causes truncation or
creation of the file.
: label
This positions a label in a command file. The label is
terminated by new-line, and blanks between the : and the
label are ignored. This command may also be used to
insert comments into a command file, since labels need
not be referenced. label may contain supplementary code
set characters.
( .,. )xb/regular expression/label
A jump (either upward or downward) is made to label if
the command succeeds. It fails under any of the
following conditions:
1. Either address is not between 1 and $.
2. The second address is less than the first.
3. The regular expression does not match at least
one line in the specified range, including the
first and last lines.
On success, . is set to the line matched and a jump is
made to label. 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
xb/^/ label
Copyright 1994 Novell, Inc. Page 2
bfs(1) bfs(1)
is an unconditional jump.
The xb 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. label may
contain supplementary code set characters.
xt number
Output from the p and null commands is truncated to at
most number displayed columns. The initial number is
255.
xv[digit][spaces][value]
The variable name is the specified digit following the
xv. The commands xv5100 or xv5 100 both assign the
value 100 to the variable 5. The command xv61,100p
assigns the value 1,100p to the variable 6. To
reference a variable, put a % in front of the variable
name. For example, using the above assignments for
variables 5 and 6:
1,%5p
1,%5
%6
all print the first 100 lines.
g/%5/p
globally searches for the characters 100 and prints each
line containing a match. To escape the special meaning
of %, a \ must precede it.
g/".*\%[cds]/p
could be used to match and list lines containing a
printf of characters, decimal integers, or strings.
Another feature of the xv command is that the first line
of output from a UNIX system command can be stored into
a variable. The only requirement is that the first
character of value be an !. For example:
.w junk
xv5!cat junk
!rm junk
!echo "%5"
xv6!expr %6 + 1
Copyright 1994 Novell, Inc. Page 3
bfs(1) bfs(1)
puts the current line into variable 5, prints it, and
increments the variable 6 by one. To escape the special
meaning of ! as the first character of value, precede
it with a \.
xv7\!date
stores the value !date into variable 7.
xbz label
xbn label
These two commands test the last saved return code from
the execution of a UNIX system command (!command) for
zero or nonzero value, respectively, and jump to the
specified label. label may contain supplementary code
set characters. The two examples below both search for
the next five lines containing the string size.
xv55
: l
/size/
xv5!expr %5 - 1
!test 0 = %5
xbn l
xv45
: l
/size/
xv4!expr %4 - 1
!test 0 != %4
xbz l
xc [switch]
If switch is 1, output from the p and null commands is
crunched; if switch is 0 it is not. Without an
argument, xc reverses switch. Initially switch is set
for no crunching. Crunched output has strings of tabs
and blanks reduced to one blank and blank lines
suppressed.
REFERENCES
csplit(1), ed(1), regexp(5), umask(1)
DIAGNOSTICS
? for errors in commands, if prompting is turned off. Self-
explanatory error messages when prompting is on.
Copyright 1994 Novell, Inc. Page 4