b

bfs(1)

bfs(1)

NAME

bfs - big ®le scanner

SYNOPSIS

bfs [-]name

DESCRIPTION

bfs is similar to ed except that it is read-only (see ed(1)) bfs can handle ®les with up to 32K − 1 lines; each line can contain up to 512 characters, including the new-line character. bfs is usually more ef®cient than ed for scanning a ®le, since the ®le is not copied to a buffer. Historically, this command was most useful for identifying sections of a large ®le where csplit could be used to divide it into more manageable pieces for editing (see csplit(1)). However, most editors now support ®les larger than the above- mentioned limits.

Normally, the size of the ®le being scanned is printed, as is the size of any ®le written with the w com- mand. The optional - suppresses printing of sizes. Input is prompted with * if P and a carriage-return are typed, as in ed. Prompting can be turned off again by inputting another P and pressing Return. Note that messages are given in response to errors if prompting is turned on.

bfs supports the Basic Regular Expression (RE) syntax (see regexp(5)) with the addition that a null RE (e.g., //) is equivalent to the last RE encountered. All address expressions described under ed are sup- ported. In addition, regular expressions can 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 can be used, and all 26 marks are remembered.

The e, g, v, k, n, 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 ®rst ten lines. The f command only prints the name of the ®le being scanned; there is no remembered ®le 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:

xf file

Further commands are taken from the named ®le. When an end-of-®le is reached, an inter-

 

rupt signal is received or an error occurs, reading resumes with the ®le containing the xf.

 

Xf commands may be nested to a depth of 10.

xo [ file ]

Further output from the p and null commands is diverted to the named ®le, which, if

 

necessary, is created mode 666. If ®le is missing, output is diverted to the standard output.

 

Note that each diversion causes truncation or creation of the ®le.

:label This positions a label in a command ®le. label is terminated by a new-line, and blanks between the : and the start of label are ignored. This command can also be used to insert comments into a command ®le, since labels need not be referenced.

(.,.)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 ®rst.

3.The regular expression does not match at least one line in the speci®ed range, including the ®rst 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. Thus it can be used to test whether addresses are bad before other commands are executed. 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.

 

xn

List the marks currently in use (marks are set by the

k command).

xt number

Output from the p and null commands is truncated to at most number characters. The ini-

 

tial number is 255.

 

Section 146

− 1 −

HP-UX Release 11i: December 2000