Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ed(1)

egrep(1)

grep(1)

sed(1)

sh(1)



  fgrep(1)                            CLIX                            fgrep(1)



  NAME

    fgrep - Searches a file for a character string

  SYNOPSIS

    fgrep [flag ... ] string [file ... ]

  FLAGS

    -b     Precedes each line by the block number on which it was found.  This
           can be useful in locating block numbers by context (first block is
           0).

    -c     Displays only a count of the lines that contain the pattern.

    -i     Ignores upper/lowercase distinction during comparisons.

    -l     Displays the names of files with matching lines once, separated by
           newlines.  Does not repeat the names of files when the pattern is
           found more than once.

    -n     Precedes each line by its line number in the file (first line is
           1).

    -v     Displays all lines except those that contain the pattern.

    -x     Displays only lines matched entirely.

    -e special_string
           Searches for a special_string (string begins with a -).

    -f file
           Takes the list of strings from file.

  DESCRIPTION

    The fgrep (fast grep) command searches files for a character string and
    displays all lines that contain that string.  The fgrep command is
    different from grep and egrep because it searches for a string, instead of
    searching for a pattern that matches an expression.  It uses a fast and
    compact algorithm.

    The characters $, *, [, ^, (, ), and \ are interpreted literally by fgrep.
    The fgrep command does not recognize full regular expressions as does
    egrep.  Since these characters have special meaning to the shell, it is
    safest to enclose the entire string in single quotes '...'.

    If no files are specified, fgrep assumes stdin.  Normally, each line found
    is copied to stdout.  The filename is displayed before each line found if
    there is more than one input file.



  2/94 - Intergraph Corporation                                              1






  fgrep(1)                            CLIX                            fgrep(1)



  EXAMPLES

    1.  To search for and display all lines containing the string ``hello'':

        fgrep hello bigfile


    2.  To display a count of all lines in bigfile which do not contain the
        string ``hello''.

        fgrep -civ hello bigfile

        This search is case-insensitive.

    3.  The following command displays the names of all files in the current
        directory which contain the string ``-hello''.

        fgrep -l -e -hello *


  NOTES

    Ideally there should be only one grep command, but there is not a single
    algorithm that spans a wide enough range of space-time tradeoffs.  Lines
    are limited to BUFSIZ characters; longer lines are truncated.  BUFSIZ is
    defined in /usr/include/stdio.h.

  DIAGNOSTICS

    fgrep: can't open file

           The file file either does not have read permission or does not
           exist.

  EXIT VALUES

    The fgrep command returns one of the following values:

    0   Matches were found

    1   No matches were found

    2   Syntax errors or inaccessible files (even if matches were found).

  RELATED INFORMATION

    Commands: ed(1), egrep(1), grep(1), sed(1), sh(1)







  2                                              Intergraph Corporation - 2/94




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026