'\"macro stdmacro
.if n .pH g1.bfs @(#)bfs	40.5 of 1/4/90
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} bfs 1 "Directory and File Management Utilities" "\&"
.if \nX=1 .ds x} bfs 1 "Directory and File Management Utilities"
.if \nX=2 .ds x} bfs 1 "" "\&"
.if \nX=3 .ds x} bfs "" "" "\&"
.TH \*(x}
.SH NAME
\f4bfs\f1 \- big file scanner
.SH SYNOPSIS
\f4bfs\f1
[
\f4\-\f1
]
.I file
.SH DESCRIPTION
The
\f4bfs\fP
command
is similar to
\f4ed\fP
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).
\f4bfs\fP
is usually more efficient than
\f4ed\fP
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
\f4csplit\fP command
can be used to divide it into more manageable pieces for editing.
.PP
Normally,
the size of the file being scanned is printed,
as is the size of any file written with the
\f4w\f1
command.
The optional
\f4\-\f1
suppresses printing of sizes.
Input is prompted with
\f4\(**\f1
if
\f4P\f1
and a carriage return are typed, as in
\f4ed\fP.
Prompting can be turned off again by
inputting another
\f4P\f1
and carriage
return.
Messages are given in response
to errors if prompting is turned on.
.PP
All address expressions described under
\f4ed\fP
are supported.
In addition, regular expressions may be surrounded with two
symbols besides
\f4/\f1
and
\f4?\f1:
\f4>\f1
indicates
downward search without wrap-around,
and
\f4<\f1
indicates upward search without wrap-around.
There is a slight difference in mark names: only the letters
\f4a\f1
through
\f4z\f1
may be used,
and all 26 marks are remembered.
.PP
The
\f4e\f1,
\f4g\f1,
\f4v\f1,
\f4k\f1,
\f4p\f1,
\f4q\f1,
\f4w\f1,
\f4=\f1,
\f4!\f1
and null
commands operate
as described under
\f4ed\fP.
Commands such as \f4\-\-\-\fP, \f4+++\-\fP,
\f4+++=\fP, \f4\-12\fP, and \f4+4p\fP are accepted.
Note that \f41,10p\fP and \f41,10\fP both print 
the first ten lines.
The
\f4f\f1
command only prints the name of the file being scanned;
there is no 
remembered
file name.
The
\f4w\f1
command is independent of output diversion,
truncation, or crunching
(see the
\f4xo\f1,
\f4xt\f1,
and
\f4xc\f1
commands, below).
The following additional commands are available:
.RS 5
.TP 5
\f4xf\f2 file\f4\^\f1
Further commands are taken from the named
.IR file .
When an end-of-file is reached,
an interrupt signal is received or an error occurs,
reading resumes with the
file containing the
\f4xf\f1.
The
\f4xf\f1
commands may be nested to a depth of 10.
.TP
\f4xn\f1
List the marks currently in use (marks are set by the
\f4k\f1
command).
.TP 
\f4xo\f2 \f1[\|\fPfile\f1\|]\fP\f4\^\f1
Further output from the
\f4p\f1
and null
commands is diverted to the named
.IR file ,
which, if necessary, is created mode 666
(readable and writable by everyone),
unless your \f4umask\fP setting dictates otherwise; see
\f4umask\fP(1).
If
.I file\^
is missing, output is diverted to the standard output.
Note that each diversion causes truncation
or creation of the file.
.TP 
\f4:\f2 label\f4\^\f1
This positions a
.I label\^
in a command file.
The
.I label\^
is terminated by new-line, and
blanks between the
\f4:\f1
and the start of the
.I label\^
are ignored.
This command may also be used to insert comments
into a command file,
since labels need not be referenced.
.TP 
( \f4. \f1, \f4. \f1)\f4xb\fP/\f2regular expression\fP/\f2label\f1
A jump (either upward or downward) is made to \f2label\fP if
the command succeeds.
It fails under any of the following conditions:
.RS 13
.ne 5
1. Either address is not between
\f41\f1
and
\f4$\f1.
.br
2. The second address is less than the first.
.br
3. The regular expression does not match at least one line
in the specified range, including the first and last lines.
.RE
.TP
\&
On success, \f4\s+3.\s0\fP is set to the line matched and a jump
is made to \f2label\fP.
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
.PP
.RS 10
.ft 4
xb/^/ label
.ft 1
.RE
.IP ""
is an unconditional jump.
.TP
\&
The
\f4xb\f1
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.
.TP
\f4xt\f2 number\f1
Output from the
\f4p\f1
and null commands is
truncated to at most
.I number\^
characters.
The initial number is 255.
.TP
\f4xv\f1[\^\f2digit\f1\^]\|[\^\f2spaces\f1\^]\|[\^\f2value\f1\^]
The variable name is the specified
.I digit\^
following the \f4xv\fP.
The commands
\f4xv5100\fP or \f4xv5 100\fP both
assign the value 
\f4100\fP to the variable
\f45\f1.
The command
\f4xv61,100p\f1
assigns the value
\f41,100p\f1
to the variable
\f46\f1.
To reference a variable, put a
\f4%\f1
in front of the variable name.
For example, using the above assignments
for variables \f45\fP and \f46\fP:
.PP
.RS 10
.ft 4
.nf
1,%5p
1,%5
%6
.fi
.ft 1
.RE
.TP
\&
all print the first 100 lines.
.PP
.RS 10
.ft 4
g/%5/p
.ft 1
.RE
.TP
\&
globally searches for the characters \f4100\fP
and prints each line containing a match.
To escape the special meaning of
\f4%\f1,
a
\f4\e\f1
must
precede it.
.PP
.RS 10
.ft 4
g/".*\\%[cds]/p
.ft 1
.RE
.TP
\&
could be used to match and list lines 
containing a
\f4printf\fP
of characters, decimal integers, or strings.
.TP
\&
Another feature of the
\f4xv\f1
command is that the first line
of output from a \s-1UNIX\s0 system command can
be stored into a variable.
The only
requirement is that the first character
of
.I value\^
be an
\f4!\fP.
For example:
.br
.ne 1.25i
.PP
.RS 10
.ft 4
.nf
\&.w junk
xv5!cat junk
!rm junk
!echo "%5"
xv6!expr %6 + 1
.fi
.ft 1
.RE
.TP
\&
puts the current line into variable \f45\fP,
prints it, and increments the variable \f46\fP by one.
To escape the special meaning of
\f4!\f1
as the
first character of
.IR value ,
precede it with a
\f4\e\fP\|.
.PP
.RS 10
.ft 4
xv7\\!date
.ft 1
.RE
.TP
\&
stores the
value \f4!date\fP into
variable \f47\fP.
.TP
\f4xbz\f2 label\f4\^\f1
.TP
\f4xbn\f2 label\f4\^\f1
These two commands test the last saved
.I "return code\^"
from the execution of a
.SM UNIX
system command
(\f4!\f2command\^\f1)
or nonzero value, respectively, to the
specified label.
The two examples below both 
search for the next five lines containing
the string \f4size\f1.
.PP
.RS 10
.ft 4
.nf
xv55
: l
/size/
xv5!expr %5 \- 1
!if 0%5 != 0 exit 2
xbn l
xv45
: l
/size/
xv4!expr %4 \- 1
!if 0%4 = 0 exit 2
xbz l
.fi
.ft 1
.RE
.TP
\f4xc\fP\ [\f2switch\fP\^]
If
.I switch\^
is \f41\fP, output from the
\f4p\f1
and null commands is crunched;
if
.I switch\^
is \f40\fP it is not.
Without an argument,
\f4xc\f1
reverses \f2switch\fP.
Initially \f2switch\fP is set for no crunching.
Crunched output has strings of tabs and blanks reduced
to one blank and blank lines suppressed.
.RE
.SH "SEE ALSO"
\f4csplit\fP(1), \f4ed\fP(1), \f4umask\fP(1).
.SH DIAGNOSTICS
\f4?\f1
for errors in commands, if prompting is turned off.
Self-explanatory error messages when prompting is on.
.\"	@(#)bfs.1	6.2 of 9/2/83
.Ee
