1 FGREP(1)                         User Commands                        FGREP(1)
   2 
   3 
   4 
   5 NAME
   6        fgrep - search a file for a fixed-character string
   7 
   8 SYNOPSIS
   9        /usr/bin/fgrep [-bcHhilnqsvx] -e pattern_list [-f file]
  10             [file...]
  11 
  12 
  13        /usr/bin/fgrep [-bcHhilnqsvx] [-e pattern_list] -f file
  14             [file...]
  15 
  16 
  17        /usr/bin/fgrep [-bcHhilnqsvx] pattern [file...]
  18 
  19 
  20 DESCRIPTION
  21        The fgrep (fast grep) utility searches files for a character string and
  22        prints all lines that contain that string. fgrep is different from
  23        grep(1) and from egrep(1) because it searches for a string, instead of
  24        searching for a pattern that matches an expression. fgrep uses a fast
  25        and compact algorithm.
  26 
  27 
  28        The characters $, *, [, ^, |, (, ), and \ are interpreted literally by
  29        fgrep, that is, fgrep does not recognize full regular expressions as
  30        does egrep. These characters have special meaning to the shell.
  31        Therefore, to be safe, enclose the entire string within single quotes
  32        (a').
  33 
  34 
  35        If no files are specified, fgrep assumes standard input. Normally, each
  36        line that is found is copied to the standard output. The file name is
  37        printed before each line that is found if there is more than one input
  38        file.
  39 
  40 OPTIONS
  41        The following options are supported:
  42 
  43        -b
  44              Precedes each line by the block number on which the line was
  45              found. This can be useful in locating block numbers by context.
  46              The first block is 0.
  47 
  48 
  49        -c
  50              Prints only a count of the lines that contain the pattern.
  51 
  52 
  53        -e pattern_list
  54              Searches for a string in pattern-list. This is useful when the
  55              string begins with a -.
  56 
  57 
  58        -f pattern-file
  59              Takes the list of patterns from pattern-file.
  60 
  61 
  62        -H
  63              Precedes each line by the name of the file containing the
  64              matching line.
  65 
  66 
  67        -h
  68              Suppresses printing of files when searching multiple files.
  69 
  70 
  71        -i
  72              Ignores upper/lower case distinction during comparisons.
  73 
  74 
  75        -l
  76              Prints the names of files with matching lines once, separated by
  77              new-lines.  Does not repeat the names of files when the pattern
  78              is found more than once.
  79 
  80 
  81        -n
  82              Precedes each line by its line number in the file. The first line
  83              is 1.
  84 
  85 
  86        -q
  87              Quiet. Does not write anything to the standard output, regardless
  88              of matching lines. Exits with zero status if an input line is
  89              selected.
  90 
  91 
  92        -s
  93              Legacy equivalent of -q.
  94 
  95 
  96        -v
  97              Prints all lines except those that contain the pattern.
  98 
  99 
 100        -x
 101              Prints only lines that are matched entirely.
 102 
 103 
 104 OPERANDS
 105        The following operands are supported:
 106 
 107        file
 108                Specifies a path name of a file to be searched for the
 109                patterns. If no file operands are specified, the standard input
 110                will be used.
 111 
 112        pattern
 113                Specifies one or more patterns to be used during the search for
 114                input. This operand is treated as if it were specified as -e
 115                pattern_list.
 116 
 117 
 118 USAGE
 119        See largefile(5) for the description of the behavior of fgrep when
 120        encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
 121 
 122 ENVIRONMENT VARIABLES
 123        See environ(5) for descriptions of the following environment variables
 124        that affect the execution of fgrep: LC_COLLATE, LC_CTYPE, LC_MESSAGES,
 125        and NLSPATH.
 126 
 127 EXIT STATUS
 128        The following exit values are returned:
 129 
 130        0
 131             If any matches are found
 132 
 133 
 134        1
 135             If no matches are found
 136 
 137 
 138        2
 139             For syntax errors or inaccessible files, even if matches were
 140             found.
 141 
 142 
 143 ATTRIBUTES
 144        See attributes(5) for descriptions of the following attributes:
 145 
 146 
 147        +---------------+-----------------+
 148        |ATTRIBUTE TYPE | ATTRIBUTE VALUE |
 149        +---------------+-----------------+
 150        |CSI            | Enabled         |
 151        +---------------+-----------------+
 152 
 153 SEE ALSO
 154        ed(1), egrep(1), grep(1), sed(1), sh(1), attributes(5), environ(5),
 155        largefile(5), XPG4(5)
 156 
 157 NOTES
 158        Ideally, there should be only one grep command, but there is not a
 159        single algorithm that spans a wide enough range of space-time
 160        tradeoffs.
 161 
 162 
 163        Lines are limited only by the size of the available virtual memory.
 164 
 165        The /usr/bin/fgrep utility is identical to /usr/bin/grep -F (see
 166        grep(1)). Portable applications should use /usr/bin/grep -F.
 167 
 168        In the past the behavior of /usr/xpg4/bin/fgrep and /usr/bin/fgrep
 169        utilities was different. Now /usr/bin/fgrep is replaced by
 170        /usr/xpg4/bin/fgrep.
 171 
 172 
 173 
 174                                November 28, 2017                      FGREP(1)