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



 191 
 192 
 193 
 194                                   May 3, 2013                         FGREP(1)
   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)