'\" te .\" CDDL HEADER START .\" .\" The contents of this file are subject to the terms of the .\" Common Development and Distribution License (the "License"). .\" You may not use this file except in compliance with the License. .\" .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE .\" or http://www.opensolaris.org/os/licensing. .\" See the License for the specific language governing permissions .\" and limitations under the License. .\" .\" When distributing Covered Code, include this CDDL HEADER in each .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. .\" If applicable, add the following below this CDDL HEADER, with the .\" fields enclosed by brackets "[]" replaced with your own identifying .\" information: Portions Copyright [yyyy] [name of copyright owner] .\" .\" CDDL HEADER END .\" Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved .\" .\" Portions Copyright (c) 2007 Gunnar Ritter, Freiburg i. Br., Germany .\" .\" Sccsid @(#)bfs.1 1.5 (gritter) 6/29/07 .\" .\" from OpenSolaris bfs 1 "20 May 1996" "SunOS 5.11" "User Commands" .TH BFS 1 "6/29/07" "Heirloom Toolchest" "User Commands" .SH NAME bfs \- big file scanner .SH SYNOPSIS \fBbfs\fR [\fB\-\fR] \fIname\fR .SH DESCRIPTION The \fBbfs\fR command is (almost) like .IR ed (1) except that it is read-only and is better suited to process larger files. \fBbfs\fR is usually more efficient than .IR 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 .IR csplit (1) 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 \fBw\fR (write) command. The optional \fB\(mi\fR suppresses printing of sizes. Input is prompted with \fB*\fR if \fBP\fR and a carriage return are typed, as in .IR ed (1). Prompting can be turned off again by inputting another \fBP\fR and carriage return. Note that messages are given in response to errors if prompting is turned on. .PP All address expressions described under .IR ed (1) are supported. In addition, regular expressions may be surrounded with two symbols besides \fB/\fR and \fB?\fR: .B > indicates downward search without wrap-around, and .B < indicates upward search without wrap-around. There is a slight difference in mark names; that is, only the letters \fBa\fR through \fBz\fR may be used, and all 26 marks are remembered. .PP The \fBe\fR, \fBg\fR, \fBv\fR, \fBk\fR, \fBp\fR, \fBq\fR, \fBw\fR, \fB=\fR, \fB!\fR, and null commands operate as described under .IR ed (1). Commands such as \fB\(mi\(mi\(mi\fR, \fB+++\(mi\fR, \fB+++=\fR, \fB\(mi12\fR, and \fB+4p\fR are accepted. Note that \fB1,10p\fR and \fB1,10\fR will both print the first ten lines. The \fBf\fR command only prints the name of the file being scanned; there is no \fIremembered\fR file name. The \fB w\fR command is independent of output diversion, truncation, or crunching (see the \fBxo\fR,\fB xt\fR, and\fB xc\fR commands, below). The following additional commands are available: .RS 5 .TP 5 \fBxf\fR\fI file\fR Further commands are taken from the named \fBfile\fR. When an end-of-file is reached, an interrupt signal is received or an error occurs, reading resumes with the file containing the \fBxf\fR. The \fBxf\fR commands may be nested to a depth of 10. .TP .B xn List the marks currently in use (marks are set by the \fBk\fR command). .TP \fBxo\fR\fI [\|file\|]\fR Further output from the \fBp\fR and null commands is diverted to the named \fBfile\fR, which, if necessary, is created mode 666 (readable and writable by everyone), unless your \fBumask\fR setting (see .IR umask (1)) dictates otherwise. If \fBfile\fR is missing, output is diverted to the standard output. Note that each diversion causes truncation or creation of the file. .TP \fB:\fR\fI label\fR This positions a \fIlabel\fR in a command file. The \fIlabel\fR is terminated by new-line, and blanks between the \fB:\fR (colon) and the start of the \fIlabel\fR are ignored. This command may also be used to insert comments into a command file, since labels need not be referenced. .TP \fB( \fB\&. \fR, \fB\&. \fR)\fBxb\fR/\fIregular expression\fR/\fIlabel\fR A jump (either upward or downward) is made to \fIlabel\fR if the command succeeds. It fails under any of the following conditions: .RS +13 1. Either address is not between \fB1\fR and \fB$\fR. .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 .RS +5 .PP On success, \fB\&.\fR (dot) is set to the line matched and a jump is made to \fIlabel\fR. 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, \fBxb/^/ label\fR, is an unconditional jump. .PP The \fBxb\fR 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. .RE .TP 5 \fBxt\fR\fI number\fR Output from the \fBp\fR and null commands is truncated to, at most, \fInumber\fR characters. The initial number is \fB255\fR. .TP 5 \fBxv\fR[\fIdigit\fR]\|[\fIspaces\fR]\|[\fIvalue\fR]\fR The variable name is the specified \fIdigit\fR following the \fBxv\fR. The commands \fBxv5100\fR or \fBxv5 100\fR both assign the value \fB100\fR to the variable \fB5\fR. The command \fBxv61,100p\fR assigns the value \fB1,100p\fR to the variable \fB6\fR. To reference a variable, put a \fB%\fR in front of the variable name. For example, using the above assignments for variables \fB5\fR and \fB6\fR: .sp .in +2 .nf 1,%5p 1,%5 %6 .fi .in -2 .sp will all print the first 100 lines. .sp .B g/%5/p .sp would globally search for the characters \fB100\fR and print each line containing a match. To escape the special meaning of \fB%\fR, a \fB\e\fR must precede it. .sp \fBg/".*\e%\fR[cds]\fB/p\fR .sp 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 \fBxv\fR command is that the first line of output from a \fBUNIX\fR system command can be stored into a variable. The only requirement is that the first character of \fIvalue\fR be an \fB!\fR. For example: .sp .in +2 .nf \fB\&.w junk xv5!cat junk !rm junk !echo "%5" xv6!expr %6 + 1\fR .fi .in -2 .sp would put the current line into variable \fB35\fR, print it, and increment the variable \fB36\fR by one. To escape the special meaning of \fB!\fR as the first character of \fIvalue\fR, precede it with a \fB\e\fR\&. .sp \fBxv7\e!date\fR .sp stores the value \fB!date\fR into variable \fB7\fR. .TP 5 \fBxbz\fR\fI label\fR .br .ns .TP 5 \fBxbn\fR\fI label\fR These two commands will test the last saved \fIreturn code\fR from the execution of a \fBUNIX\fR system command (\fB!\fR\fBcommand\fR) or nonzero value, respectively, to the specified label. The two examples below both search for the next five lines containing the string \fBsize\fR: .sp .in +2 .nf \fBxv55 : l /size/ xv5!expr %5 \(mi 1 !if 0%5 != 0 exit 2 xbn l\fR .fi .in -2 .sp .in +2 .nf \fBxv45 : l /size/ xv4!expr %4 \(mi 1 !if 0%4 = 0 exit 2 xbz l\fR .fi .in -2 .TP \fBxc\fR [\fBswitch\fR]\fR If \fBswitch\fR is \fB1\fR, output from the \fBp\fR and null commands is crunched; if \fBswitch\fR is \fB0\fR, it is not. Without an argument, \fBxc\fR reverses \fBswitch\fR. Initially, \fBswitch\fR is set for no crunching. Crunched output has strings of tabs and blanks reduced to one blank and blank lines suppressed. .RE .SH "ENVIRONMENT VARIABLES" .TP .BR LANG ", " LC_ALL See .IR locale (7). .TP .B LC_CTYPE Determines the mapping of bytes to characters in regular expressions and with the .I xt command. .SH SEE ALSO .IR csplit (1), .IR ed (1), .IR umask (1) .SH DIAGNOSTICS Message is \fB?\fR for errors in commands, if prompting is turned off. Self-explanatory error messages are displayed when prompting is on.