bfs - big file scanner
/usr/bin/bfs [-] filename
The bfs command is (almost) like ed(1) 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). bfs is usually more efficient than ed(1) 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 csplit(1) 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 (write) command. The optional - suppresses printing of sizes. Input is prompted with * if P and a carriage return are typed, as in ed(1). Prompting can be turned off again by inputting another P and carriage return. Note that messages are given in response to errors if prompting is turned on.
All address expressions described under ed(1) are supported. In addition, regular expressions may be surrounded with two symbols besides / and ?:
>
<
There is a slight difference in mark names; that is, 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 under ed(1). Commands such as ---, +++-, +++=, -12, and +4p are accepted. Note that 1,10p and 1,10 will 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:
xf file
xn
xo [file]
: label
( . , . )xb/regular expression/label
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
xv[digit][spaces][value]
1,%5p 1,%5 %6
will all print the first 100 lines.
g/%5/p
would globally search for the characters 100 and print 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 %c, %d, or %s formats (for example, "printf"-like statements) 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
would put the current line into variable 35, print it, and increment the variable 36 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
Example 1:
xv55 : l /size/ xv5!expr %5 - 1 !if 0%5 != 0 exit 2 xbn l
Example 2:
xv45 : l /size/ xv4!expr %4 - 1 !if 0%4 = 0 exit 2 xbz l
xc [switch]
The following operand is supported:
filename
The following exit values are returned:
0
>0
See attributes(5) for descriptions of the following attributes:
|
csplit(1), ed(1), umask(1), attributes(5)
Message is ? for errors in commands, if prompting is turned off. Self-explanatory error messages are displayed when prompting is on.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |