1GREP(1)                          User Commands                         GREP(1)
2
3
4

NAME

6       grep, egrep, fgrep - print lines that match patterns
7

SYNOPSIS

9       grep [OPTION...] PATTERNS [FILE...]
10       grep [OPTION...] -e PATTERNS ... [FILE...]
11       grep [OPTION...] -f PATTERN_FILE ... [FILE...]
12

DESCRIPTION

14       grep  searches  for PATTERNS in each FILE.  PATTERNS is one or patterns
15       separated by newline characters, and grep prints each line that matches
16       a pattern.
17
18       A  FILE  of  “-”  stands  for  standard  input.   If  no FILE is given,
19       recursive searches examine  the  working  directory,  and  nonrecursive
20       searches read standard input.
21
22       In  addition,  the  variant  programs  egrep  and fgrep are the same as
23       grep -E and grep -F, respectively.  These variants are deprecated,  but
24       are provided for backward compatibility.
25

OPTIONS

27   Generic Program Information
28       --help Output a usage message and exit.
29
30       -V, --version
31              Output the version number of grep and exit.
32
33   Matcher Selection
34       -E, --extended-regexp
35              Interpret  PATTERNS  as  extended regular expressions (EREs, see
36              below).
37
38       -F, --fixed-strings
39              Interpret PATTERNS as fixed strings, not regular expressions.
40
41       -G, --basic-regexp
42              Interpret PATTERNS  as  basic  regular  expressions  (BREs,  see
43              below).  This is the default.
44
45       -P, --perl-regexp
46              Interpret   PATTERNS   as  Perl-compatible  regular  expressions
47              (PCREs).  This option is experimental when combined with the  -z
48              (--null-data)  option,  and  grep  -P  may warn of unimplemented
49              features.
50
51   Matching Control
52       -e PATTERNS, --regexp=PATTERNS
53              Use PATTERNS as the patterns.  If this option is  used  multiple
54              times or is combined with the -f (--file) option, search for all
55              patterns given.  This option can be used to  protect  a  pattern
56              beginning with “-”.
57
58       -f FILE, --file=FILE
59              Obtain patterns from FILE, one per line.  If this option is used
60              multiple times or is combined with  the  -e  (--regexp)  option,
61              search  for  all  patterns  given.  The empty file contains zero
62              patterns, and therefore matches nothing.
63
64       -i, --ignore-case
65              Ignore case distinctions, so that characters that differ only in
66              case match each other.
67
68       -v, --invert-match
69              Invert the sense of matching, to select non-matching lines.
70
71       -w, --word-regexp
72              Select  only  those  lines  containing  matches  that form whole
73              words.  The test is that the matching substring must  either  be
74              at  the  beginning  of  the  line,  or  preceded  by  a non-word
75              constituent character.  Similarly, it must be either at the  end
76              of  the  line  or  followed by a non-word constituent character.
77              Word-constituent  characters  are  letters,  digits,   and   the
78              underscore.  This option has no effect if -x is also specified.
79
80       -x, --line-regexp
81              Select  only  those  matches  that exactly match the whole line.
82              For a regular expression pattern, this  is  like  parenthesizing
83              the pattern and then surrounding it with ^ and $.
84
85       -y     Obsolete synonym for -i.
86
87   General Output Control
88       -c, --count
89              Suppress  normal output; instead print a count of matching lines
90              for each input file.  With the -v,  --invert-match  option  (see
91              below), count non-matching lines.
92
93       --color[=WHEN], --colour[=WHEN]
94              Surround   the  matched  (non-empty)  strings,  matching  lines,
95              context lines, file  names,  line  numbers,  byte  offsets,  and
96              separators  (for fields and groups of context lines) with escape
97              sequences to display them in color on the terminal.  The  colors
98              are  defined  by  the  environment  variable  GREP_COLORS.   The
99              deprecated environment variable GREP_COLOR is  still  supported,
100              but  its setting does not have priority.  WHEN is never, always,
101              or auto.
102
103       -L, --files-without-match
104              Suppress normal output; instead print the  name  of  each  input
105              file from which no output would normally have been printed.  The
106              scanning will stop on the first match.
107
108       -l, --files-with-matches
109              Suppress normal output; instead print the  name  of  each  input
110              file  from  which  output would normally have been printed.  The
111              scanning will stop on the first match.
112
113       -m NUM, --max-count=NUM
114              Stop reading a file after NUM matching lines.  If the  input  is
115              standard  input  from a regular file, and NUM matching lines are
116              output, grep ensures that the standard input  is  positioned  to
117              just  after the last matching line before exiting, regardless of
118              the presence of trailing context lines.  This enables a  calling
119              process  to resume a search.  When grep stops after NUM matching
120              lines, it outputs any trailing context lines.  When  the  -c  or
121              --count  option  is  also  used,  grep  does  not output a count
122              greater than NUM.  When the -v or --invert-match option is  also
123              used, grep stops after outputting NUM non-matching lines.
124
125       -o, --only-matching
126              Print  only  the  matched  (non-empty) parts of a matching line,
127              with each such part on a separate output line.
128
129       -q, --quiet, --silent
130              Quiet;  do  not  write  anything  to  standard   output.    Exit
131              immediately  with  zero status if any match is found, even if an
132              error was detected.  Also see the -s or --no-messages option.
133
134       -s, --no-messages
135              Suppress error messages about nonexistent or unreadable files.
136
137   Output Line Prefix Control
138       -b, --byte-offset
139              Print the 0-based byte offset within the input file before  each
140              line of output.  If -o (--only-matching) is specified, print the
141              offset of the matching part itself.
142
143       -H, --with-filename
144              Print the file name for each match.  This is  the  default  when
145              there is more than one file to search.
146
147       -h, --no-filename
148              Suppress  the  prefixing  of  file names on output.  This is the
149              default when there is only one file (or only standard input)  to
150              search.
151
152       --label=LABEL
153              Display  input  actually  coming  from  standard  input as input
154              coming  from  file  LABEL.   This  is  especially  useful   when
155              implementing  tools  like  zgrep,  e.g.,  gzip -cd foo.gz | grep
156              --label=foo -H something.  See also the -H option.
157
158       -n, --line-number
159              Prefix each line of output with the 1-based line  number  within
160              its input file.
161
162       -T, --initial-tab
163              Make  sure  that the first character of actual line content lies
164              on a tab stop, so that the alignment of tabs looks normal.  This
165              is  useful  with  options that prefix their output to the actual
166              content: -H,-n, and -b.  In order  to  improve  the  probability
167              that lines from a single file will all start at the same column,
168              this also causes the line number and byte offset (if present) to
169              be printed in a minimum size field width.
170
171       -u, --unix-byte-offsets
172              Report  Unix-style  byte  offsets.   This  switch causes grep to
173              report byte offsets as if the file were a Unix-style text  file,
174              i.e.,  with  CR  characters  stripped  off.   This  will produce
175              results identical to running  grep  on  a  Unix  machine.   This
176              option  has  no  effect unless -b option is also used; it has no
177              effect on platforms other than MS-DOS and MS-Windows.
178
179       -Z, --null
180              Output a zero byte (the ASCII  NUL  character)  instead  of  the
181              character  that normally follows a file name.  For example, grep
182              -lZ outputs a zero byte after each  file  name  instead  of  the
183              usual  newline.   This option makes the output unambiguous, even
184              in the presence of file names containing unusual characters like
185              newlines.   This  option  can  be  used  with commands like find
186              -print0, perl -0, sort -z, and xargs  -0  to  process  arbitrary
187              file names, even those that contain newline characters.
188
189   Context Line Control
190       -A NUM, --after-context=NUM
191              Print  NUM  lines  of  trailing  context  after  matching lines.
192              Places a line containing  a  group  separator  (described  under
193              --group-separator)  between  contiguous groups of matches.  With
194              the -o or --only-matching option,  this  has  no  effect  and  a
195              warning is given.
196
197       -B NUM, --before-context=NUM
198              Print  NUM  lines  of  leading  context  before  matching lines.
199              Places a line containing  a  group  separator  (described  under
200              --group-separator)  between  contiguous groups of matches.  With
201              the -o or --only-matching option,  this  has  no  effect  and  a
202              warning is given.
203
204       -C NUM, -NUM, --context=NUM
205              Print  NUM  lines of output context.  Places a line containing a
206              group  separator  (described  under  --group-separator)  between
207              contiguous  groups  of  matches.  With the -o or --only-matching
208              option, this has no effect and a warning is given.
209
210       --group-separator=SEP
211              Use SEP as a group separator. By default SEP  is  double  hyphen
212              (--).
213
214       --no-group-separator
215              Use empty string as a group separator.
216
217   File and Directory Selection
218       -a, --text
219              Process  a binary file as if it were text; this is equivalent to
220              the --binary-files=text option.
221
222       --binary-files=TYPE
223              If a file's data or metadata indicate  that  the  file  contains
224              binary  data,  assume  that  the file is of type TYPE.  Non-text
225              bytes indicate binary data; these are either output  bytes  that
226              are  improperly  encoded  for  the current locale, or null input
227              bytes when the -z option is not given.
228
229              By default, TYPE is binary, and when grep discovers that a  file
230              is  binary it suppresses any further output, and instead outputs
231              either a one-line message saying that a binary file matches,  or
232              no message if there is no match.
233
234              If  TYPE  is  without-match,  when grep discovers that a file is
235              binary it assumes that the rest of the file does not match; this
236              is equivalent to the -I option.
237
238              If  TYPE  is  text,  grep  processes a binary file as if it were
239              text; this is equivalent to the -a option.
240
241              When type is binary, grep  may  treat  non-text  bytes  as  line
242              terminators  even  without  the  -z option.  This means choosing
243              binary versus text can affect whether a pattern matches a  file.
244              For  example,  when  type is binary the pattern q$ might match q
245              immediately followed by a null byte, even  though  this  is  not
246              matched  when type is text.  Conversely, when type is binary the
247              pattern . (period) might not match a null byte.
248
249              Warning: The -a option might output binary  garbage,  which  can
250              have  nasty  side effects if the output is a terminal and if the
251              terminal driver interprets some of it as commands.  On the other
252              hand,  when  reading  files whose text encodings are unknown, it
253              can  be  helpful  to  use  -a  or  to  set  LC_ALL='C'  in   the
254              environment,  in  order to find more matches even if the matches
255              are unsafe for direct display.
256
257       -D ACTION, --devices=ACTION
258              If an input file is a device, FIFO  or  socket,  use  ACTION  to
259              process  it.   By  default,  ACTION  is  read,  which means that
260              devices are read just as if they were ordinary files.  If ACTION
261              is skip, devices are silently skipped.
262
263       -d ACTION, --directories=ACTION
264              If  an  input file is a directory, use ACTION to process it.  By
265              default, ACTION is read, i.e., read directories just as if  they
266              were   ordinary   files.   If  ACTION  is  skip,  silently  skip
267              directories.  If ACTION is recurse, read all  files  under  each
268              directory,  recursively,  following  symbolic links only if they
269              are on the command line.  This is equivalent to the -r option.
270
271       --exclude=GLOB
272              Skip any command-line file with a name suffix that  matches  the
273              pattern  GLOB,  using wildcard matching; a name suffix is either
274              the whole name, or any suffix starting after a /  and  before  a
275              non-/.   When searching recursively, skip any subfile whose base
276              name matches GLOB; the base name is the part after the  last  /.
277              A pattern can use *, ?, and [...] as wildcards, and \ to quote a
278              wildcard or backslash character literally.
279
280       --exclude-from=FILE
281              Skip files whose base name matches any of  the  file-name  globs
282              read  from  FILE  (using  wildcard  matching  as described under
283              --exclude).
284
285       --exclude-dir=GLOB
286              Skip any command-line directory with a name suffix that  matches
287              the   pattern   GLOB.   When  searching  recursively,  skip  any
288              subdirectory whose base name matches GLOB.  Ignore any redundant
289              trailing slashes in GLOB.
290
291       -I     Process  a  binary  file as if it did not contain matching data;
292              this is equivalent to the --binary-files=without-match option.
293
294       --include=GLOB
295              Search only files whose base name matches GLOB  (using  wildcard
296              matching as described under --exclude).
297
298       -r, --recursive
299              Read  all  files  under  each  directory, recursively, following
300              symbolic links only if they are on the command line.  Note  that
301              if   no  file  operand  is  given,  grep  searches  the  working
302              directory.  This is equivalent to the -d recurse option.
303
304       -R, --dereference-recursive
305              Read all files under each directory,  recursively.   Follow  all
306              symbolic links, unlike -r.
307
308   Other Options
309       --line-buffered
310              Use  line  buffering  on  output.   This can cause a performance
311              penalty.
312
313       -U, --binary
314              Treat the file(s) as binary.  By default, under MS-DOS  and  MS-
315              Windows,  grep  guesses  whether  a  file  is  text or binary as
316              described for the --binary-files option.  If  grep  decides  the
317              file  is  a  text  file,  it  strips  the CR characters from the
318              original file contents (to make regular expressions with ^ and $
319              work   correctly).   Specifying  -U  overrules  this  guesswork,
320              causing all  files  to  be  read  and  passed  to  the  matching
321              mechanism  verbatim; if the file is a text file with CR/LF pairs
322              at  the  end  of  each  line,  this  will  cause  some   regular
323              expressions  to  fail.   This  option has no effect on platforms
324              other than MS-DOS and MS-Windows.
325
326       -z, --null-data
327              Treat  input  and  output  data  as  sequences  of  lines,  each
328              terminated by a zero byte (the ASCII NUL character) instead of a
329              newline.  Like the -Z or --null option, this option can be  used
330              with commands like sort -z to process arbitrary file names.
331

REGULAR EXPRESSIONS

333       A  regular  expression  is  a  pattern that describes a set of strings.
334       Regular  expressions  are   constructed   analogously   to   arithmetic
335       expressions, by using various operators to combine smaller expressions.
336
337       grep understands three different versions of regular expression syntax:
338       “basic” (BRE), “extended” (ERE) and “perl” (PCRE).  In GNU  grep  there
339       is  no difference in available functionality between basic and extended
340       syntaxes.  In other implementations, basic regular expressions are less
341       powerful.   The  following  description  applies  to  extended  regular
342       expressions; differences for basic regular expressions  are  summarized
343       afterwards.    Perl-compatible   regular  expressions  give  additional
344       functionality, and are documented in pcresyntax(3) and  pcrepattern(3),
345       but work only if PCRE is available in the system.
346
347       The  fundamental building blocks are the regular expressions that match
348       a single character.  Most characters, including all letters and digits,
349       are regular expressions that match themselves.  Any meta-character with
350       special meaning may be quoted by preceding it with a backslash.
351
352       The period . matches any single character.  It is  unspecified  whether
353       it matches an encoding error.
354
355   Character Classes and Bracket Expressions
356       A  bracket  expression is a list of characters enclosed by [ and ].  It
357       matches any single character in that list.  If the first  character  of
358       the  list is the caret ^ then it matches any character not in the list;
359       it is unspecified whether it matches an encoding error.   For  example,
360       the regular expression [0123456789] matches any single digit.
361
362       Within  a  bracket  expression,  a  range  expression  consists  of two
363       characters separated by a hyphen.  It matches any single character that
364       sorts  between  the  two  characters,  inclusive,  using  the  locale's
365       collating sequence and character set.  For example, in  the  default  C
366       locale, [a-d] is equivalent to [abcd].  Many locales sort characters in
367       dictionary  order,  and  in  these  locales  [a-d]  is  typically   not
368       equivalent to [abcd]; it might be equivalent to [aBbCcDd], for example.
369       To obtain the traditional interpretation of  bracket  expressions,  you
370       can  use the C locale by setting the LC_ALL environment variable to the
371       value C.
372
373       Finally, certain named classes  of  characters  are  predefined  within
374       bracket expressions, as follows.  Their names are self explanatory, and
375       they  are  [:alnum:],  [:alpha:],  [:cntrl:],   [:digit:],   [:graph:],
376       [:lower:],  [:print:], [:punct:], [:space:], [:upper:], and [:xdigit:].
377       For example, [[:alnum:]] means  the  character  class  of  numbers  and
378       letters in the current locale.  In the C locale and ASCII character set
379       encoding, this is the same as [0-9A-Za-z].  (Note that the brackets  in
380       these  class names are part of the symbolic names, and must be included
381       in addition to the brackets delimiting the bracket  expression.)   Most
382       meta-characters  lose their special meaning inside bracket expressions.
383       To include a literal ] place it  first  in  the  list.   Similarly,  to
384       include a literal ^ place it anywhere but first.  Finally, to include a
385       literal - place it last.
386
387   Anchoring
388       The caret ^ and the dollar sign $ are meta-characters that respectively
389       match the empty string at the beginning and end of a line.
390
391   The Backslash Character and Special Expressions
392       The  symbols  \<  and  \>  respectively  match  the empty string at the
393       beginning and end of a word.  The symbol \b matches the empty string at
394       the  edge  of a word, and \B matches the empty string provided it's not
395       at the edge of a word.  The symbol \w is a synonym for [_[:alnum:]] and
396       \W is a synonym for [^_[:alnum:]].
397
398   Repetition
399       A  regular  expression  may  be  followed  by one of several repetition
400       operators:
401       ?      The preceding item is optional and matched at most once.
402       *      The preceding item will be matched zero or more times.
403       +      The preceding item will be matched one or more times.
404       {n}    The preceding item is matched exactly n times.
405       {n,}   The preceding item is matched n or more times.
406       {,m}   The preceding item is matched at most m times.  This  is  a  GNU
407              extension.
408       {n,m}  The  preceding  item  is  matched at least n times, but not more
409              than m times.
410
411   Concatenation
412       Two regular expressions may  be  concatenated;  the  resulting  regular
413       expression  matches  any  string formed by concatenating two substrings
414       that respectively match the concatenated expressions.
415
416   Alternation
417       Two regular expressions may be joined by  the  infix  operator  |;  the
418       resulting   regular  expression  matches  any  string  matching  either
419       alternate expression.
420
421   Precedence
422       Repetition takes precedence over concatenation,  which  in  turn  takes
423       precedence  over  alternation.   A  whole expression may be enclosed in
424       parentheses  to  override   these   precedence   rules   and   form   a
425       subexpression.
426
427   Back References and Subexpressions
428       The back-reference \n, where n is a single digit, matches the substring
429       previously matched  by  the  nth  parenthesized  subexpression  of  the
430       regular expression.
431
432   Basic vs Extended Regular Expressions
433       In  basic  regular expressions the meta-characters ?, +, {, |, (, and )
434       lose their special meaning; instead use the  backslashed  versions  \?,
435       \+, \{, \|, \(, and \).
436

ENVIRONMENT VARIABLES

438       The   behavior  of  grep  is  affected  by  the  following  environment
439       variables.
440
441       The locale for category LC_foo is  specified  by  examining  the  three
442       environment  variables  LC_ALL, LC_foo, LANG, in that order.  The first
443       of these variables that is set specifies the locale.  For  example,  if
444       LC_ALL  is not set, but LC_MESSAGES is set to pt_BR, then the Brazilian
445       Portuguese locale is used for the LC_MESSAGES category.  The  C  locale
446       is  used  if none of these environment variables are set, if the locale
447       catalog is not installed, or if grep was  not  compiled  with  national
448       language support (NLS).  The shell command locale -a lists locales that
449       are currently available.
450
451       GREP_OPTIONS
452              This variable specifies default options to be placed in front of
453              any  explicit  options.   As  this  causes problems when writing
454              portable scripts, this feature  will  be  removed  in  a  future
455              release  of  grep,  and grep warns if it is used.  Please use an
456              alias or script instead.
457
458       GREP_COLOR
459              This variable specifies the  color  used  to  highlight  matched
460              (non-empty) text.  It is deprecated in favor of GREP_COLORS, but
461              still supported.  The mt, ms, and mc capabilities of GREP_COLORS
462              have  priority  over  it.  It can only specify the color used to
463              highlight the matching non-empty text in any  matching  line  (a
464              selected  line  when the -v command-line option is omitted, or a
465              context line when -v is specified).  The default is 01;31, which
466              means  a  bold  red  foreground  text  on the terminal's default
467              background.
468
469       GREP_COLORS
470              Specifies the colors and  other  attributes  used  to  highlight
471              various  parts  of  the  output.  Its value is a colon-separated
472              list      of      capabilities      that       defaults       to
473              ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36  with  the  rv
474              and ne boolean capabilities omitted  (i.e.,  false).   Supported
475              capabilities are as follows.
476
477              sl=    SGR  substring  for  whole selected lines (i.e., matching
478                     lines when the -v command-line option is omitted, or non-
479                     matching  lines  when  -v  is specified).  If however the
480                     boolean rv capability and the -v command-line option  are
481                     both  specified,  it  applies  to  context matching lines
482                     instead.  The default  is  empty  (i.e.,  the  terminal's
483                     default color pair).
484
485              cx=    SGR substring for whole context lines (i.e., non-matching
486                     lines when the -v  command-line  option  is  omitted,  or
487                     matching  lines  when  -v  is specified).  If however the
488                     boolean rv capability and the -v command-line option  are
489                     both specified, it applies to selected non-matching lines
490                     instead.  The default  is  empty  (i.e.,  the  terminal's
491                     default color pair).
492
493              rv     Boolean  value  that reverses (swaps) the meanings of the
494                     sl= and cx= capabilities when the -v command-line  option
495                     is specified.  The default is false (i.e., the capability
496                     is omitted).
497
498              mt=01;31
499                     SGR substring for matching non-empty text in any matching
500                     line  (i.e.,  a  selected  line  when the -v command-line
501                     option  is  omitted,  or  a  context  line  when  -v   is
502                     specified).   Setting  this is equivalent to setting both
503                     ms= and mc= at once to the same value.  The default is  a
504                     bold   red   text   foreground   over  the  current  line
505                     background.
506
507              ms=01;31
508                     SGR substring for matching non-empty text in  a  selected
509                     line.  (This is only used when the -v command-line option
510                     is omitted.)  The effect  of  the  sl=  (or  cx=  if  rv)
511                     capability  remains  active  when  this  kicks  in.   The
512                     default is a bold red text foreground  over  the  current
513                     line background.
514
515              mc=01;31
516                     SGR  substring  for  matching non-empty text in a context
517                     line.  (This is only used when the -v command-line option
518                     is  specified.)   The  effect  of  the cx= (or sl= if rv)
519                     capability  remains  active  when  this  kicks  in.   The
520                     default  is  a  bold red text foreground over the current
521                     line background.
522
523              fn=35  SGR substring for file names prefixing any content  line.
524                     The  default  is  a  magenta  text  foreground  over  the
525                     terminal's default background.
526
527              ln=32  SGR substring for  line  numbers  prefixing  any  content
528                     line.   The  default  is a green text foreground over the
529                     terminal's default background.
530
531              bn=32  SGR substring for  byte  offsets  prefixing  any  content
532                     line.   The  default  is a green text foreground over the
533                     terminal's default background.
534
535              se=36  SGR substring for separators that  are  inserted  between
536                     selected  line  fields  (:), between context line fields,
537                     (-), and between groups of adjacent  lines  when  nonzero
538                     context  is  specified  (--).  The default is a cyan text
539                     foreground over the terminal's default background.
540
541              ne     Boolean value that prevents clearing to the end  of  line
542                     using  Erase  in  Line  (EL) to Right (\33[K) each time a
543                     colorized item ends.  This  is  needed  on  terminals  on
544                     which  EL  is  not  supported.  It is otherwise useful on
545                     terminals for which the  back_color_erase  (bce)  boolean
546                     terminfo  capability  does  not  apply,  when  the chosen
547                     highlight colors do not affect the background, or when EL
548                     is  too  slow or causes too much flicker.  The default is
549                     false (i.e., the capability is omitted).
550
551              Note that boolean capabilities have  no  =...  part.   They  are
552              omitted (i.e., false) by default and become true when specified.
553
554              See   the   Select   Graphic  Rendition  (SGR)  section  in  the
555              documentation of the text terminal that is  used  for  permitted
556              values   and  their  meaning  as  character  attributes.   These
557              substring values are integers in decimal representation and  can
558              be  concatenated with semicolons.  grep takes care of assembling
559              the result into a  complete  SGR  sequence  (\33[...m).   Common
560              values to concatenate include 1 for bold, 4 for underline, 5 for
561              blink, 7 for inverse, 39 for default foreground color, 30 to  37
562              for  foreground  colors,  90  to 97 for 16-color mode foreground
563              colors, 38;5;0 to 38;5;255  for  88-color  and  256-color  modes
564              foreground colors, 49 for default background color, 40 to 47 for
565              background colors, 100  to  107  for  16-color  mode  background
566              colors,  and 48;5;0 to 48;5;255 for 88-color and 256-color modes
567              background colors.
568
569       LC_ALL, LC_COLLATE, LANG
570              These variables specify the locale for the LC_COLLATE  category,
571              which  determines the collating sequence used to interpret range
572              expressions like [a-z].
573
574       LC_ALL, LC_CTYPE, LANG
575              These variables specify the locale for  the  LC_CTYPE  category,
576              which  determines the type of characters, e.g., which characters
577              are whitespace.  This category  also  determines  the  character
578              encoding,  that  is, whether text is encoded in UTF-8, ASCII, or
579              some other encoding.  In the C or POSIX locale,  all  characters
580              are  encoded  as  a  single  byte  and  every  byte  is  a valid
581              character.
582
583       LC_ALL, LC_MESSAGES, LANG
584              These variables specify the locale for the LC_MESSAGES category,
585              which  determines the language that grep uses for messages.  The
586              default C locale uses American English messages.
587
588       POSIXLY_CORRECT
589              If set, grep behaves as POSIX requires; otherwise, grep  behaves
590              more  like other GNU programs.  POSIX requires that options that
591              follow file names must be treated as  file  names;  by  default,
592              such  options  are permuted to the front of the operand list and
593              are treated as options.  Also, POSIX requires that  unrecognized
594              options be diagnosed as “illegal”, but since they are not really
595              against the law the default is to diagnose  them  as  “invalid”.
596              POSIXLY_CORRECT   also   disables  _N_GNU_nonoption_argv_flags_,
597              described below.
598
599       _N_GNU_nonoption_argv_flags_
600              (Here N is grep's numeric process ID.)  If the ith character  of
601              this  environment variable's value is 1, do not consider the ith
602              operand of grep to be an option, even if it appears to  be  one.
603              A  shell  can  put  this  variable  in  the environment for each
604              command it runs, specifying which operands are  the  results  of
605              file name wildcard expansion and therefore should not be treated
606              as options.  This behavior is available  only  with  the  GNU  C
607              library, and only when POSIXLY_CORRECT is not set.
608

EXIT STATUS

610       Normally the exit status is 0 if a line is selected, 1 if no lines were
611       selected, and 2 if an error occurred.  However, if the -q or --quiet or
612       --silent  is  used and a line is selected, the exit status is 0 even if
613       an error occurred.
614
616       Copyright 1998–2000, 2002, 2005–2018 Free Software Foundation, Inc.
617
618       This is free software; see the source for copying conditions.  There is
619       NO  warranty;  not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
620       PURPOSE.
621

BUGS

623   Reporting Bugs
624       Email bug reports to the bug-reporting address ⟨bug-grep@gnu.org⟩.   An
625       email  archive  ⟨https://lists.gnu.org/mailman/listinfo/bug-grep⟩ and a
626       bug  tracker   ⟨https://debbugs.gnu.org/cgi/pkgreport.cgi?package=grep
627       are available.
628
629   Known Bugs
630       Large  repetition  counts  in the {n,m} construct may cause grep to use
631       lots of memory.  In addition, certain other obscure regular expressions
632       require  exponential  time  and space, and may cause grep to run out of
633       memory.
634
635       Back-references are very slow, and may require exponential time.
636

SEE ALSO

638   Regular Manual Pages
639       awk(1), cmp(1), diff(1), find(1), gzip(1),  perl(1),  sed(1),  sort(1),
640       xargs(1),  zgrep(1),  read(2),  pcre(3), pcresyntax(3), pcrepattern(3),
641       terminfo(5), glob(7), regex(7).
642
643   POSIX Programmer's Manual Page
644       grep(1p).
645
646   Full Documentation
647       A complete manual ⟨https://www.gnu.org/software/grep/manual/⟩ is avail‐
648       able.   If  the  info  and grep programs are properly installed at your
649       site, the command
650
651              info grep
652
653       should give you access to the complete manual.
654

NOTES

656       This man page is maintained only fitfully; the  full  documentation  is
657       often more up-to-date.
658
659
660
661GNU grep 3.3                      2018-05-11                           GREP(1)
Impressum