Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (HP-UX-11.11)
Apropos / Subsearch:
optional field

 bfs(1)								      bfs(1)

      bfs - big file scanner

      bfs [-] name

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

      Normally, the size of the file being scanned is printed, as is the
      size of any file written with the w command.  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
      supported.  In addition, regular expressions can be surrounded with
      two symbols besides / and ?: >&gt&gt> indicates downward search without
      wrap-around, and <&lt&lt&lt; 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 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	     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 commands may be nested to a
		     depth of 10.

      xo [file]	     Further output from the p and null commands is diverted
		     to the named file, which, if necessary, is created mode
		     666.  If file is missing, output is diverted to the
		     standard output.  Note that each diversion causes
		     truncation or creation of the file.

 Hewlett-Packard Company	    - 1 -   HP-UX Release 11i: November 2000

 bfs(1)								      bfs(1)

      : label	     This positions a label in a command file.	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 file, 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 first.
			  3.  The regular expression does not match at least
			      one line in the specified range, including the
			      first 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


		     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

      xt number	     Output from the p and null commands is truncated to at
		     most number characters.  The initial number is 255.

		     The variable name is the specified digit following the
		     xv.  xv5100 or xv5 100 both assign the value 100 to the
		     variable 5.  Xv61,100p assigns the value 1,100p to the
		     variable 6.  To reference a variable, put a % in front
		     of the variable name.  For example, using the above
		     assignments for variables 5 and 6:


		     all print the first 100 lines.

 Hewlett-Packard Company	    - 2 -   HP-UX Release 11i: November 2000

 bfs(1)								      bfs(1)


		     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, to
		     match and list lines in a program file that contain
		     printf() format strings specifying characters, decimal
		     integers, or strings, the following could be used:


		     Another feature of the xv command is that the first
		     line of output from an HP-UX 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

		     each put the current line into variable 5, print it,
		     and increment the variable 6 by one.  To escape the
		     special meaning of ! as the first character of value,
		     precede it with a \.


		     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 HP-UX system command (!command) for
		     a zero or non-zero value, respectively, and cause a
		     branch to the specified label.  The two examples below
		     both search for the next five lines containing the
		     string size.

		     First example:

			  : l
			  xv5!expr %5 - 1
			  !if [ %5 != 0 ] ; then exit 2 ; fi
			  xbn l

		     Second Example:

 Hewlett-Packard Company	    - 3 -   HP-UX Release 11i: November 2000

 bfs(1)								      bfs(1)

			  : l
			  xv4!expr %4 - 1
			  !if [ %4 = 0 ] ; then exit 2 ; fi
			  xbz l

      xc [switch]    If switch is 1, output from the p and null commands is
		     crunched; if switch is 0 it isn't.	 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

    Environment Variables
      LC_COLLATE determines the collating sequence used in evaluating
      regular expressions.

      LC_CTYPE determines the classification of characters as letters, and
      the characters matched by character class expressions in regular

      If LC_COLLATE or LC_CTYPE is not specified in the environment or is
      set to the empty string, the value of LANG is used as a default for
      each unspecified or empty variable.  If LANG is not specified or is
      set to the empty string, a default of "C" (see lang(5)) is used
      instead of LANG.	If any internationalization variable contains an
      invalid setting, bfs behaves as if all internationalization variables
      are set to "C".  See environ(5).

    International Code Set Support
      Single-byte character code sets are supported.

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

      csplit(1), ed(1), lang(5), regexp(5).

 Hewlett-Packard Company	    - 4 -   HP-UX Release 11i: November 2000