BFS(1)

NAME
bfs - big file scanner

SYNOPSIS
bfs [ - ] filename

DESCRIPTION
bfs allows you to scan through large files using line addresses similar to those for ed(1). bfs is read-only and processes files as large as 1024K bytes, or 32K lines with up to 512 characters each, including the newline. bfs is usually more efficient for scanning than ed, since the file is not copied to a buffer. It is useful for identifying places in a large file where it can be divided using csplit(1).

Normally, the size of the file being scanned is printed, as is the size of any file written with the w command.

With the - flag, suppress printing of file sizes.

USAGE

  Line Addressing

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. There is a slight difference in mark names: only the letters a through z may be used, and all 26 marks are remembered.

  Commands

The commands e, g, v, k, p, q, =, !, and the null command operate as described in ed(1). Commands such as ---, +++-, +++=, -12, and +4p are accepted. Note that 1,10p and 1,10 both print the first ten lines.

P RETURN
    toggle prompting for input (with *) and display of error messages.

f   print the name of the file being scanned; there is no remembered file name.

w   command is similar to that of ed(1), but is independent of output diversion, truncation, or crunching (see the xo, xt and xc commands, below).

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 mode 666. 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 newline. Blanks between the : and the start of label are ignored. This command may also be used to insert comments into a command file, since labels need not be referenced.

( . , . )xb/regular expression/label
    Jump 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.
    This command does not issue an error message on bad addresses. Note that the command
        xb/^/ label
    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.
xt number
    Output from the p and null commands is truncated to at most number characters. The initial number is 255.
xv[digit] [value]
    Assign a value to the variable named digit following the xv.
    The commands
        xv5100
    and
        xv5 100p assign the value 100 to the variable 5, and the value 100p to the variable 6, respectively.
    To express a variable's value, prepend a % to the variable name. For example, using the above assignments for variables 5 and 6:
        1,%5p
        1,%5p
        %6
    will each print the first 100 lines.
    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 a !. For example:
        .w junk
        xv5!cat junk
        !rm junk
        To include ! as the first character of value, precede it with a \.
            xv7\!date
    This stores the value !date in variable 7.
xbz label
xbn label
    These two commands will test the last saved return code from the execution of a UNIX system command (!command) or nonzero value, respectively, to the specified label. The two examples below both search for the next five lines containing the string size.
    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

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.

SEE ALSO
csplit(1), ed(1), regcmp(3X)

DIAGNOSTICS

?   for errors in commands, if prompting is turned off. Self-explanatory error messages when prompting is on.