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

NAME

6       agrep - print lines approximately matching a pattern
7

SYNOPSIS

9       agrep [OPTION]...  PATTERN [FILE]...
10

DESCRIPTION

12       Searches  for  approximate  matches of PATTERN in each FILE or standard
13       input.   Example: `agrep -2 optimize foo.txt' outputs all lines in file
14       `foo.txt'  that  match  "optimize" within two errors.  E.g. lines which
15       contain "optimise", "optmise", and "opitmize" all match.
16

OPTIONS

18   Regexp selection and interpretation:
19       -e PATTERN, --regexp=PATTERN
20              Use PATTERN as a regular expression; useful to protect  patterns
21              beginning with -.
22
23       -i, --ignore-case
24              Ignore  case  distinctions (as defined by the current locale) in
25              PATTERN and input files.
26
27       -k, --literal
28              Treat PATTERN as a literal string, that is, a fixed string  with
29              no special characters.
30
31       -w, --word-regexp
32              Force  PATTERN  to  match only whole words.  A "whole word" is a
33              substring which either starts at the beginning or the record  or
34              is  preceded  by  a non-word constituent character.   Similarly,
35              the substring must either end at the end of  the  record  or  be
36              followed  by a non-word constituent character.  Word-constituent
37              characters are alphanumerics (as defined by the current  locale)
38              and  the  underscore  character.   Note  that  the non-word con‐
39              stituent characters must surround  the  match;  they  cannot  be
40              counted as errors.
41
42   Approximate matching settings:
43       -D NUM, --delete-cost=NUM
44              Set cost of missing characters to NUM.
45
46       -I NUM, --insert-cost=NUM
47              Set cost of extra characters to NUM.
48
49       -S NUM, --substitute-cost=NUM
50              Set  cost  of incorrect characters to NUM.  Note that a deletion
51              (a missing character) and  an  insertion  (an  extra  character)
52              together  constitute  a substituted character, but the cost will
53              be the that of a  deletion  and  an  insertion  added  together.
54              Thus,  if  the  const of a substitution is set to be larger than
55              the sum of the costs of deletion and insertion, direct substitu‐
56              tions will never be done.
57
58       -E NUM, --max-errors=NUM
59              Select records that have at most NUM errors.
60
61       -#     Select  records that have at most # errors (# is a digit between
62              0 and 9).
63
64   Miscellaneous:
65       -d PATTERN, --delimiter=PATTERN
66              Set the record delimiter regular  expression  to  PATTERN.   The
67              text  between  two  delimiters,  before the first delimiter, and
68              after the last delimiter is considered  to  be  a  record.   The
69              default  record  delimiter  is  the regexp "\n", so by default a
70              record is a line.  PATTERN can be any  regular  expression  that
71              does not match the empty string.  For example, using -d "^From "
72              defines mail messages as records in a Mailbox format file.
73
74       -v, --invert-match
75              Select non-matching records instead of matching records.
76
77       -V, --version
78              Print version information and exit.
79
80       -y, --nothing
81              Does nothing.  This options exists only for  compatibility  with
82              the non-free agrep program.
83
84       --help Display a brief help message and exit.
85
86   Output control:
87       -B, --best-match
88              Only output the best matching records, that is, the records with
89              the lowest cost.  This is currently implemented  by  making  two
90              passes over the input files and cannot be used when reading from
91              standard input.
92
93       --color, --colour
94              Highlight the matching  strings  in  the  output  with  a  color
95              marker.   The color string is taken from the GREP_COLOR environ‐
96              ment variable.  The default color is red.
97
98       -c, --count
99              Only print a count of matching records per each input file, sup‐
100              pressing normal output.
101
102       -h, --no-filename
103              Suppress  the  prefixing  filename on output when multiple files
104              are searched.
105
106       -H, --with-filename
107              Prefix each output record with the name of the input file  where
108              the record was read from.
109
110       -l, --files-with-matches
111              Only  print  the name of each input file which contains at least
112              one match, suppressing normal output.   The  scanning  for  each
113              file will stop on the first match.
114
115       -n, --record-number
116              Prefix  each output record with its sequence number in the input
117              file.  The number of the first record is 1.
118
119       -q, --quiet, --silent
120              Do not write anything to standard output.  Exit immediately with
121              zero exit status if a match is found.
122
123       -s, --show-cost
124              Print match cost with output.
125
126       --show-position
127              Prefix  each  output record with the start and end offset of the
128              first match within the record.  The offset of the first  charac‐
129              ter of the record is 0.  The end position is given as the offset
130              of the first character after the match.
131
132       -M, --delimiter-after
133              By default, the record delimiter is the newline character and is
134              output  after  the  matching  record.  If -d is used, the record
135              delimiter will be  output  before  the  matching  record.   This
136              option  causes  the  delimiter  to  be output after the matching
137              record.
138
139       With no FILE, or when FILE is -, reads standard input.   If  less  than
140       two FILEs are given -h is assumed, otherwise -H is the default.
141

DIAGNOSTICS

143       Exit  status  is  0 if a match is found, 1 for no match, and 2 if there
144       were errors.  If -E or -# is not  specified,  only  exact  matches  are
145       selected.
146
147       PATTERN  is  a  POSIX  extended  regular  expression (ERE) with the TRE
148       extensions.
149

REPORTING BUGS

151       Report bugs to the TRE mailing list <tre-general@lists.laurikari.net>.
152
154       Copyright © 2002-2004 Ville Laurikari.
155       This is free software, and comes with ABSOLUTELY NO WARRANTY.  You  are
156       welcome to redistribute this software under certain conditions; see the
157       source for the full license text.
158
159
160
161TRE agrep 0.8.0                November 21, 2004                      agrep(1)
Impressum