• Aucun résultat trouvé

bfs [-] name

Description

hfs is like ed (C) except that it is read-only and processes much larger files. Files can be up to l024K bytes and 32K lines, with up to 255 characters per line. hfs is usually more efficient than ed for scanning a file, since the file is not copied to a buffer. It is most useful for iden-tifying sections of a large file where csplit(C) can be used to divide it into more manageable pieces for editing.

Normally, the size of the file being scanned is printed, as is the size of any file written with the w command. The optional dash (-) suppresses printing of sizes. Input is prompted for with an asterisk (*) when "P" and RETURN are typed. The "P" acts as a toggle, so prompting can be turned off again by entering another "P" and a RETURN. Note that messages are given in response to errors only if prompting is turned on.

All address expressions described under ed are supported. In addition, regular expressions may be surrounded with two symbols other than the standard slash (I) and (?): A greater-than sign (» indicates down-ward search without wraparound, and a less-than sign «) indicates upward search without wraparound. Note that parentheses and curly braces are special and need to be escaped with a backslash (\). Since hfs uses a different regular expression-matching routine from ed, the regular expressions accepted are slightly wider in scope (see regex (S». Differences between ed and hfs are listed below:

+ A regular expression followed by + means one or more times.

For example, [0-9]+ is equivalent to [0-9][0-9]*.

\{m\} \{m,\} \{m,u\}

Integer values enclosed in \{ \} indicate the number of times the preceding regular expression is to be applied. m is the minimum number and u is a number, less than 256, which is the maximum. If only m is present (e.g., \{ m\}), it indicates the exact number of times the regular expression is to be applied. \{ m,\} is analogous to \{ m,infinity\} . The plus (+) and star (*) operations are equivalent to \{ l,\} and \{ O,\}

respectively.

March 11, 1990 BFS-1

BFS(C) BFS (C)

( 0 0 0 )$n The value of the enclosed regular expression is to be returned. The value will be stored in the (n+ 1 )th argument following the subject argument. At most ten enclosed regular expressions are allowed. regex makes its assignments uncon-ditionally.

(000) Parentheses are used for grouping. An operator, e.g. *, +,

\{ \}, can work on a single character or a regular expression enclosed in parenthesis. For example, \(a*\(cb+\)*\)$O.

There is also a slight difference in mark names: only the letters "a"

through "z" may be used, and all 26 marks are remembered.

The e, g, v, k, p, q, w, =, ! and null commands operate as described filename. The w command is independent of output diversion, trunca-tion' or crunching (see the XO, xt and xc commands, below). The fol-lowing additional commands are available:

xffile

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. xf com-mands may be nested to a depth of 10.

2. The second address is less than the first.

March 11, 1990 BFS-2

BFS(C) BFS(C) 3. The regular expression doesn't match at least one line

in the specified range, including the first and last lines.

On success, dot (.) is set to the line matched and a jump is made to label. This command is the only one that doesn't 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 xbr/label

is an unconditional jump.

The xb command is allowed only if it is read from somewhere 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 a max-imum of number characters. The initial number is 255.

xv[ digit] [spaces] [value]

The variable name is the specified digit following the xv.

xv5100 or xvS 100 both assign the value 100 to the variable 5.

xv61,100p assigns the value 1,100p to the variable 6. To refer-ence 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

prints the first 100 lines.

gI%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. For example,

gi". *\%[cds]/p

could be used to match and list lines containing print! charac-ters, decimal integers, or strings.

Another feature of the xv command is that the first line of output from a Altos UNIX System V command can be stored into a variable.

March 11, 1990 BFS-3

BFS (C) BFS (C) The only requirement is that the first character of value be a !.

For example, xv5 !cat junk

!rmjunk

!echo "%5"

xv6!expr %6 + 1

puts the current line in 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 \. For example,

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 an Altos UNIX System V command (!command) or nonzero value, respectively, and jump to the specified label.

The two examples below search for the next five lines contain-ing the strcontain-ing size:

xc [switch]

xv55 : I /size/

xv5 !expr %5 - 1

!if 0%5 != 0 exit 2 xbnl

xv45 : I /size/

xv4!expr %4 - 1

!if 0%4 = 0 exit 2 xbz I

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(C), ed(C), umask(C)

March 11, 1990 BFS-4

BFS (C)

Diagnostics

BFS (C)

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

March 11, 1 990 BFS-5

CAL (C) CAL (C)

cal

prints a calendar