Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages
EGREP(1) User Commands EGREP(1)

egrep - search a file for a pattern using full regular expressions

/usr/local/heirloom/usr/5bin/egrep [-e pattern_list ...] [ -f pattern_file] [ -bchilnrRvz] [ pattern_list] [ file ...]
/usr/local/heirloom/usr/5bin/posix/egrep -e pattern_list ... [ -f pattern_file] [ -c|-l|-q] [ -bhinrRsvxz] [ file ...]
/usr/local/heirloom/usr/5bin/posix/egrep -f pattern_file [ -e pattern_list ...] [ -c|-l|-q] [ -bhinrRsvxz] [file ...]
/usr/local/heirloom/usr/5bin/posix/egrep [-c|-l| -q] [-bhinsrRvxz] pattern_list [file ...]

The egrep command searches the lines of the specified files (or of standard input) for occurrences of pattern. The default behavior is to print each matching line to standard output.
The /usr/local/heirloom/usr/5bin/egrep command accepts full regular expressions; it uses a deterministic algorithm with moderate space requirements.
The /usr/local/heirloom/usr/5bin/posix/egrep command accepts extended regular expressions. It uses a deterministic algorithm with moderate space requirements unless the expression includes multi-character collating elements, which cause the use of a nondeterministic algorithm.
/usr/local/heirloom/usr/5bin/s42/egrep and /usr/local/heirloom/usr/5bin/posix2001/egrep are identical to /usr/local/heirloom/usr/5bin/posix/egrep.

In the following description `character' excludes newline:
A \ followed by a single character matches that character.
The character ^ ( $) matches the beginning (end) of a line as an anchor.
A . matches any character.
A single character not otherwise endowed with special meaning matches that character.
A string enclosed in brackets [] forms a bracket expression that matches any single character from the string. Ranges of ASCII character codes may be abbreviated as in ` a-z0- 9'. A ] may occur only as the first character of the string. A literal - must be placed where it can't be mistaken as a range indicator.
A regular expression followed by * (+, ?) matches a sequence of 0 or more (1 or more, 0 or 1) matches of the regular expression.
Two regular expressions concatenated match a match of the first followed by a match of the second.
Two regular expressions separated by | or newline match either a match for the first or a match for the second ( alternation).
A regular expression enclosed in parentheses () matches a match for the regular expression ( grouping).
The order of precedence of operators is [] then () then *+? then concatenation then | and newline.

Extended Regular Expressions add the following features to Full Regular Expressions:
A regular expression followed by {m,n} forms an interval expression that matches a sequence of m through n matches, inclusive, of the regular expression. The values of m and n must be non-negative and smaller than 255. The form {m} matches exactly m occurrences, { m,} matches at least m occurrences.
In bracket expressions as described in 5., the following character sequences are considered special:
Character class expressions of the form [:class:]. In the C LC_CTYPE locale, the classes
[:alnum:] [:cntrl:] [:lower:] [:space:]
[:alpha:] [:digit:] [:print:] [:upper:]
[:blank:] [:graph:] [:punct:] [:xdigit:]
are recognized; further locale-specific classes may be available. A character class expression matches any character that belongs to the given class in the current LC_CTYPE locale.
Collating symbol expressions of the form [.c.], where c is a collating symbol in the current LC_COLLATE locale. A collating symbol expression matches the specified collating symbol.
Equivalence class expressions of the form [=c=], where c is a collating symbol in the current LC_COLLATE locale. An equivalence class expression matches any character that has the same collating weight as c.
The order of precedence of operators is [==] [::] [..] then [] then () then *+? {m,n} then concatenation then ^ $ then | and newline.
Care should be taken when using the characters $ * [ ^ | ? ´ " ( ) and \ in the expression as they are also meaningful to the Shell. It is safest to enclose the entire expression argument in single quotes ´ ´.
Both /usr/local/heirloom/usr/5bin/egrep and /usr/local/heirloom/usr/5bin/posix/egrep accept the following options:
Each line is preceded by the block number on which it was found. This is sometimes useful in locating disk block numbers by context. Block numbers start with 0.
Only a count of matching lines is printed.
-e pattern_list
Specifies one or more patterns, separated by newline characters. A line is selected if one or more of the specified patterns are found.
-f pattern_file
One or more patterns, separated by newline characters, are read from pattern_file. If multiple -e or -f options are supplied to /usr/local/heirloom/usr/5bin/posix/egrep, all of the pattern lists will be evaluated.
Normally, the name of each input file is printed before a match if there is more that one input file. When this option is present, no file names are printed.
Upper- and lowercase differences are ignored when searching matches.
The names of files with matching lines are listed (once) separated by newlines.
Each line is preceded by its line number in the file. Line numbers start with 1.
All lines but those matching are printed.
The following options are supported by /usr/local/heirloom/usr/5bin/posix/egrep only:
Do not write anything to standard output.
Error messages for nonexistent or unreadable files are suppressed.
Consider only lines consisting of the pattern as a whole, like a regular expression surrounded by ^ and $.
The following options are supported as extensions:
With this option given, egrep does not directly search in each given file that is a directory, but descends it recursively and scans each regular file found below it. Device files are ignored. Symbolic links are followed.
Operates recursively as with the -r option, but does not follow symbolic links that point to directories unless if they are explicitly specified as arguments.
If an input file is found to be compressed with compress(1), gzip(1), or bzip2(1), the appropriate compression program is started, and egrep searches for the pattern in its output.

See locale(7).
Affects the collation order for range expressions, equivalence classes, and collation symbols in extended regular expressions.
Determines the mapping of bytes to characters in both full and extended regular expressions, the availability and composition of character classes in extended regular expressions, and the case mapping for the -i option.

ed(1), fgrep(1), grep(1), sed(1), locale(7)

Exit status is 0 if any matches are found, 1 if none, 2 for syntax errors or inaccessible files.

If a line contains a NUL character, only matches up to this character are found with /usr/local/heirloom/usr/5bin/posix/egrep. The entire matching line will be printed.
The LC_COLLATE variable has currently no effect. Ranges in bracket expressions are ordered as byte values in single-byte locales and as wide character values in multibyte locales; equivalence classes match the given character only, and multi-character collating elements are not available.
For portable programs, restrict textual data to the US-ASCII character set, set the LC_CTYPE and LC_COLLATE variables to `C' or `POSIX', and use the constructs in the second column instead of the character class expressions as follows:
[[:alnum:]] [0-9A-Za-z]
[[:alpha:]] [A-Za-z]
[[:blank:]] [<tab><space>]
[[:cntrl:]] [^<space>-~]
[[:digit:]] [0-9]
[[:graph:]] [!-~]
[[:lower:]] [a-z]
[[:print:]] [<space>-~]
[[:punct:]] [!-/:-@[-`{-~]
[[:space:]] [<tab><vt><ff><cr><space>]
[[:upper:]] [A-Z]
[[:xdigit:]] [0-9a-fA-F]
<tab>, <space>, <vt>, <ff>, and <cr> indicate inclusion of a literal tabulator, space, vertical tabulator, formfeed, or carriage return character, respectively. Do not put the <vt>, <ff>, and <cr> characters into the range expression for the space class unless you actually want to match these characters.
Interval expressions were newly introduced with extended regular expressions and cannot be used in portable programs. To put a literal `{' character into an expression, use [{].
8/14/05 Heirloom Toolchest

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.