1GREP(1)                     General Commands Manual                    GREP(1)
2
3
4

NAME

6       grep, egrep, fgrep - print lines matching a pattern
7

SYNOPSIS

9       grep [OPTIONS] PATTERN [FILE...]
10       grep [OPTIONS] -e PATTERN ... [FILE...]
11       grep [OPTIONS] -f FILE ... [FILE...]
12

DESCRIPTION

14       grep  searches  for  PATTERN  in  each  FILE.  A FILE of “-” stands for
15       standard input.  If no FILE is given, recursive  searches  examine  the
16       working  directory,  and nonrecursive searches read standard input.  By
17       default, grep prints the matching lines.
18
19       In addition, the variant programs egrep  and  fgrep  are  the  same  as
20       grep -E  and grep -F, respectively.  These variants are deprecated, but
21       are provided for backward compatibility.
22

OPTIONS

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

REGULAR EXPRESSIONS

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

ENVIRONMENT VARIABLES

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

EXIT STATUS

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

BUGS

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

SEE ALSO

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

NOTES

653       This  man  page  is maintained only fitfully; the full documentation is
654       often more up-to-date.
655
656
657
658User Commands                    GNU grep 3.1                          GREP(1)
Impressum