The Help Page for AGREP 3.35 / 3.37

Approximate Pattern Matching GREP -- Get Regular Expression
compiled for DOS and OS/2 and Windows with EMX 0.9c or Borland C 5.02 or Microsoft VisualC VC 5.0.
Manber/Wu/Gries et al. ©1989-1998

This page has been updated on July 1, 2002

Usage


AGREP [options] [-f patternfile] pattern [files]

A first example:
A second example:

A Warning

The search pattern must be enclosed in "double quotes" if it contains one of the following metasymbols. A good practice is always to include the search pattern in double quotes.

Options

-#  find matches with at most # errors     -A  always output filenames
-c  output the number of matched records   -B  find best match to the pattern
-d  define record delimiter                -Dk deletion cost is k
-e  for use when pattern begins with -     -G  output the files with a match
-f  name of file containing patterns       -Ik insertion cost is k
-h  do not display file names              -Sk substitution cost is k
-i  case-insensitive search; ISO <> ASCII  -ia ISO chars mapped to lower ASCII
-i# digits-match-digits, letters-letters   -i0 case-sensitive search
-k  treat pattern literally - no meta-characters
-l  output the names of files that contain a match
-n  output record prefixed by line number
-p  supersequence search                   -CP 850|437 set codepage
-r  recurse subdirectories (UNIX style)    -s silent
-t  for use when delimiter is at the end of records
-v  output those records without matches   -V[012345V] version / verbose more
-w  pattern has to match as a word: "win" will not match "wind"
-x  pattern must match a whole line
-y  suppresses the prompt when used with -B option
@listfile  use the filenames in listfile
back to the top of this page
back to AGREP

Metasymbols

\z turns off any special meaning of character z (\# matches #)
^ begin-of-line symbol
$ end-of-line symbol
. matches any single character (except newline)
# matches any number > 0 of arbitrary characters
(×)* matches zero or more instances of preceding token × (Kleene closure)
×(×)* matches one or more instances of preceding token × (Positive closure)
(Use this as replacement for (×)+ which is not implemented yet.)

Sets

[b-dq-tz] matches characters b c d q r s t z
[^b-diq-tz] matches all characters except b c d i q r s t z
ab|cd matches "ab" or "cd"
<abcd> matches exactly, no errors allowed in string "abcd"
(overrides the -1 option)

Operators (and, or)

The operators ; (and) and , (or) must not appear together in a pattern.
cat;dog matches records having "cat" and "dog"
cat,dog matches records having "cat" or "dog"

The Kleene closure of the language A is the language formed by the union of zero and more concatenations of A.
The Positive closure of the language A is the language formed by the union of one and more concatenations of A.

back to the top of this page
back to AGREP


Examples

agrep "colo#r" foo
agrep -2 -ci miscellaneous foo
agrep "^From#\.edu$" foo
agrep "abc[0-9](de|fg)*[x-z]" foo
agrep -d "^From " "search;retriev" mbox
agrep -1 -d "$$" "<bug> <report>" foo
agrep -p "EPO" foo
agrep -i# "11zz11" foo
agrep -isV0 needle foo
case-insensitive search for needle in file foo with no output at all.
The -V0 option even avoids the display of number of "Grand Total" matches.


back to the top of this page
back to AGREP


Special Topics

And, how to search for double quotes " ?
You could use "SET AGREPOPTS=<your options>" to change the default options.
The codepage setting
The search is case-sensitive by default (-i0).
The default verbose option is 1 (-V1)


back to the top of this page
back to AGREP


AGREP 3.35-3.37 The Help Page T.Gries

back to my home page