bfs(1) bfs(1)NAME bfs - edits big files SYNOPSIS bfs [-] file ARGUMENTS - Suppresses the display of the size of the file when bfs starts and when you use the w command. file Specifies the name of the file to edit. This argument is required. DESCRIPTION bfs is a read-only editor that can process much larger files than standard editors. Files can contain up to 1 million bytes, with up to 32,000 lines. A line can contain up to 512 characters, including a terminating newline character. If bfs encounters a line that is too long, it displays the message line too long and exits. The bfs command is similar to ed but more efficient because it does not copy the file to a buffer. You can use bfs to identify and split sections of a large file into small files that can be modified later by a text editor such as vi, or you can use the information gained from using bfs to run csplit on the file. Prompting If you type the letter P and press RETURN, bfs displays an asterisk (*) as a prompt, as in ed. You can turn the prompt off by typing P and pressing RETURN again. Compatibilities with ed The bfs command supports all address expressions described in ed(1). In addition to the slash (/) and the question mark (?) provided by ed, you can surround regular expressions with the greater-than symbol (>), which indicates downward search without wrap-around, and the lesser-than symbol (<), which indicates upward search without wrap-around. There is a slight difference from ed with regard to mark names: bfs supports only the letters a through z and remembers all 26 marks. The e, g, v, k, P, p, q, w, =, !, and null commands operate as described in ed(1). The w command works independently from the bfs-specific xo, xt, and xc commands. The bfs command accepts such complex commands as ---, +++-, +++=, -12, and +4p. Note that both 1,10p and 1,10 cause the display of the first ten lines of the file. January 1992 1
bfs(1) bfs(1)The bfs and ed commands both have an f command, but when you are using bfs, the f command only displays the name of the file currently being read; you cannot use it to edit a new file. bfs-specific Commands Once you have started bfs on a file, you can use these bfs commands: :label Creates a label in a command file. If you use optional white-space characters to separate the colon (:) and the label, bfs ignores them. Because bfs does not require that labels be referenced, you can use this command to insert comments in a command file. (. , . )xb/regular-expression/label Jumps upward or downward to label if the command succeeds. The xb command is valid only if read from someplace other than a terminal. If the command is read from a pipe, only a downward jump is possible. The command fails under any of these conditions: ⊕ Either address is not between 1 and $. ⊕ The second address is less than the first. ⊕ The regular expression does not match at least one line in the specified range, including the first and last lines. On success, a period (.) is set to the matched line and a jump is made to label. This command is the only command that does not issue an error message on bad addresses, so you can use it to test whether addresses are bad before executing other commands. This xb command is an unconditional jump: xb/^/ label xc [switch] Converts sequences of tabs and spaces to a single space and suppresses blank lines in the output from the p and null commands if the value of switch is 1. If the value of switch is 0, the action of xc is turned off. If you do not supply switch, the action of xc is toggled. When you first start bfs, the action of xc is turned off. xbz label xbn label 2 January 1992
bfs(1) bfs(1)Test the exit code of the most recently executed shell command (!command) for a zero or a nonzero value, respectively, and go to the specified label if the test succeeds. These two examples search for the next five lines containing the string size: xv55 : here /size/ xv5!expr %5 - 1 !if [ %5 != 0 ]; then exit 2; fi xbn here xv45 : there /size/ xv4!expr %4 - 1 !if [ %4 = 0]; then exit 2; fi xbz there xf command-file Specifies a command file from which further bfs commands are taken. When bfs reaches the end of the file or receives an interrupt signal, or if an error occurs, reading resumes with the file containing the xf command. You can nest xf commands to a depth of 10. xn Lists the marks currently in use. See the k command in ed(1) for information about setting marks. xo [file] Diverts further output from the p and null commands to file, which, if necessary, is created with permission bits of 666. If the file already exists, it is truncated. If you do not specify file, bfs diverts the output to the standard output. xt number Truncates output from the p and null commands to most number characters. The default is 255. xv Assigns value to the variable specified by digit. For example, xv5100 or xv5 100 both assign the value 100 to the variable 5. The command xv61,100p assigns the value 1,100p to the variable 6. To reference a variable, put a percent sign (%) in front of the variable name. For example, using the assignments just given for variables 5 and 6, these commands cause bfs to display the first 100 lines of the file: 1,%5p January 1992 3
bfs(1) bfs(1)1,%5 %6 Using the assignment just given for variable 5, this command searches the file for the character string 100 and displays each line that contains a match: g/%5/p To escape the special meaning of %, a backslash (\) must precede %. For example, this command displays the lines that contain printf conversion formats for characters, decimal integers, and strings: g/".*\%[cds]/p You can also use the xv command to store into a variable the first line of output from a command run by the shell. The only requirement is that the first character of value be an exclamation mark (!). For example, this sequence stores the first line of the output of date into variable 7 and displays its contents: xv7!date !echo %7 This sequence writes the current line to a file called junk, stores the contents of junk in variable 5, removes junk, and displays the contents of variable 5: .w junk xv5!cat junk !rm junk !echo "%5" To escape the special meaning of ! as the first character of value, precede it with a backslash (\). EXAMPLES This command runs bfs on a file named text: bfs text STATUS MESSAGES AND VALUES If the * prompt is turned on, the bfs command displays a question mark (?) for errors in commands and displays self- explanatory error messages. 4 January 1992
bfs(1) bfs(1)FILES /bin/bfs Executable file SEE ALSO csplit(1), ed(1) regcmp(3X) in A/UX Programmer's Reference January 1992 5