www.delorie.com/gnu/docs/grep/grep_4.html   search  
Buy GNU books!

grep, print lines matching a pattern

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.2 Environment Variables

Grep's behavior is affected by the following environment variables.

A locale LC_foo is specified by examining the three environment variables LC_ALL, LC_foo, and LANG, in that order. The first of these variables that is set specifies the locale. For example, if LC_ALL is not set, but LC_MESSAGES is set to `pt_BR', then Brazilian Portuguese is used for the LC_MESSAGES locale. The C locale is used if none of these environment variables are set, or if the locale catalog is not installed, or if grep was not compiled with national language support (NLS).

This variable specifies default options to be placed in front of any explicit options. For example, if GREP_OPTIONS is `--binary-files=without-match --directories=skip', grep behaves as if the two options `--binary-files=without-match' and `--directories=skip' had been specified before any explicit options. Option specifications are separated by whitespace. A backslash escapes the next character, so it can be used to specify an option containing whitespace or a backslash.

This variable specifies the surrounding markers use to highlight the matching text. The default is control ascii red.

These variables specify the LC_COLLATE locale, which determines the collating sequence used to interpret range expressions like `[a-z]'.

These variables specify the LC_CTYPE locale, which determines the type of characters, e.g., which characters are whitespace.

These variables specify the LC_MESSAGES locale, which determines the language that grep uses for messages. The default C locale uses American English messages.

If set, grep behaves as POSIX.2 requires; otherwise, grep behaves more like other GNU programs. POSIX.2 requires that options that follow file names must be treated as file names; by default, such options are permuted to the front of the operand list and are treated as options. Also, POSIX.2 requires that unrecognized options be diagnosed as "illegal", but since they are not really against the law the default is to diagnose them as "invalid". POSIXLY_CORRECT also disables _N_GNU_nonoption_argv_flags_, described below.

(Here N is grep's numeric process ID.) If the ith character of this environment variable's value is `1', do not consider the ith operand of grep to be an option, even if it appears to be one. A shell can put this variable in the environment for each command it runs, specifying which operands are the results of file name wildcard expansion and therefore should not be treated as options. This behavior is available only with the GNU C library, and only when POSIXLY_CORRECT is not set.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003