| @@ -1,182 +1,194 @@ | | | @@ -1,182 +1,194 @@ |
1 | .TH agrep 1 "November 21, 2004" "TRE agrep 0.8.0" | | 1 | .TH agrep 1 "November 21, 2004" "TRE agrep 0.8.0" |
2 | .SH NAME | | 2 | .SH NAME |
3 | agrep \- print lines approximately matching a pattern | | 3 | agrep \- print lines approximately matching a pattern |
4 | .SH SYNOPSIS | | 4 | .SH SYNOPSIS |
5 | .B agrep | | 5 | .B agrep |
6 | .RI [ OPTION ]... | | 6 | .RI [ OPTION ]... |
7 | .I PATTERN | | 7 | .I PATTERN |
8 | .RI [ FILE ]... | | 8 | .RI [ FILE ]... |
9 | .SH DESCRIPTION | | 9 | .SH DESCRIPTION |
10 | Searches for approximate matches of PATTERN in each FILE or standard | | 10 | Searches for approximate matches of PATTERN in each FILE or standard |
11 | input. Example: `agrep \-2 optimize foo.txt' outputs all lines in | | 11 | input. |
12 | file `foo.txt' that match "optimize" within two errors. E.g. lines | | 12 | Example: `agrep \-2 optimize foo.txt' outputs all lines in |
13 | which contain "optimise", "optmise", and "opitmize" all match. | | 13 | file `foo.txt' that match "optimize" within two errors. |
| | | 14 | E.g. lines which contain "optimise", "optmise", and "opitmize" all |
| | | 15 | match. |
14 | .SH OPTIONS | | 16 | .SH OPTIONS |
15 | .SS "Regexp selection and interpretation:" | | 17 | .SS "Regexp selection and interpretation:" |
16 | .TP | | 18 | .TP |
17 | .BI \-e " PATTERN" "\fR,\fP \-\^\-regexp=" PATTERN | | 19 | .BI \-e " PATTERN" "\fR,\fP \-\^\-regexp=" PATTERN |
18 | Use | | 20 | Use |
19 | .I PATTERN | | 21 | .I PATTERN |
20 | as a regular expression; useful to protect patterns beginning with | | 22 | as a regular expression; useful to protect patterns beginning with |
21 | .BR \- . | | 23 | .BR \- . |
22 | .TP | | 24 | .TP |
23 | .BR \-i ", " \-\^\-ignore\-case | | 25 | .BR \-i ", " \-\^\-ignore\-case |
24 | Ignore case distinctions (as defined by the current locale) in | | 26 | Ignore case distinctions (as defined by the current locale) in |
25 | .I PATTERN | | 27 | .I PATTERN |
26 | and input files. | | 28 | and input files. |
27 | .TP | | 29 | .TP |
28 | .BR \-k ", " \-\^\-literal | | 30 | .BR \-k ", " \-\^\-literal |
29 | Treat | | 31 | Treat |
30 | .I PATTERN | | 32 | .I PATTERN |
31 | as a literal string, that is, a fixed string with no special | | 33 | as a literal string, that is, a fixed string with no special |
32 | characters. | | 34 | characters. |
33 | .TP | | 35 | .TP |
34 | .BR \-w ", " \-\^\-word\-regexp | | 36 | .BR \-w ", " \-\^\-word\-regexp |
35 | Force | | 37 | Force |
36 | .I PATTERN | | 38 | .I PATTERN |
37 | to match only whole words. A "whole word" is a substring which either | | 39 | to match only whole words. |
38 | starts at the beginning or the record or is preceded by a non-word | | 40 | A "whole word" is a substring which either starts at the beginning |
39 | constituent character. Similarly, the substring must either end at | | 41 | or the record or is preceded by a non-word constituent character. |
40 | the end of the record or be followed by a non-word constituent | | 42 | Similarly, the substring must either end at the end of the record |
41 | character. Word-constituent characters are alphanumerics (as | | 43 | or be followed by a non-word constituent character. |
42 | defined by the current locale) and the underscore character. Note | | 44 | Word-constituent characters are alphanumerics (as |
43 | that the non-word constituent characters | | 45 | defined by the current locale) and the underscore character. |
| | | 46 | Note that the non-word constituent characters |
44 | .B must | | 47 | .B must |
45 | surround the match; they cannot be counted as errors. | | 48 | surround the match; they cannot be counted as errors. |
46 | .SS "Approximate matching settings:" | | 49 | .SS "Approximate matching settings:" |
47 | .TP | | 50 | .TP |
48 | .BI \-D " NUM" "\fR,\fP \-\^\-delete\-cost=" NUM | | 51 | .BI \-D " NUM" "\fR,\fP \-\^\-delete\-cost=" NUM |
49 | Set cost of missing characters to | | 52 | Set cost of missing characters to |
50 | .IR NUM . | | 53 | .IR NUM . |
51 | .TP | | 54 | .TP |
52 | .BI \-I " NUM" "\fR,\fP \-\^\-insert\-cost=" NUM | | 55 | .BI \-I " NUM" "\fR,\fP \-\^\-insert\-cost=" NUM |
53 | Set cost of extra characters to | | 56 | Set cost of extra characters to |
54 | .IR NUM . | | 57 | .IR NUM . |
55 | .TP | | 58 | .TP |
56 | .BI \-S " NUM" "\fR,\fP \-\^\-substitute\-cost=" NUM | | 59 | .BI \-S " NUM" "\fR,\fP \-\^\-substitute\-cost=" NUM |
57 | Set cost of incorrect characters to | | 60 | Set cost of incorrect characters to |
58 | .IR NUM . | | 61 | .IR NUM . |
59 | Note that a deletion (a missing character) and an insertion (an extra | | 62 | Note that a deletion (a missing character) and an insertion (an extra |
60 | character) together constitute a substituted character, but the cost | | 63 | character) together constitute a substituted character, but the cost |
61 | will be the that of a deletion and an insertion added together. Thus, | | 64 | will be the that of a deletion and an insertion added together. |
62 | if the const of a substitution is set to be larger than the sum | | 65 | Thus, if the const of a substitution is set to be larger than the |
63 | of the costs of deletion and insertion, direct substitutions will | | 66 | sum of the costs of deletion and insertion, direct substitutions |
64 | never be done. | | 67 | will never be done. |
65 | .TP | | 68 | .TP |
66 | .BI \-E " NUM" "\fR,\fP \-\^\-max\-errors=" NUM | | 69 | .BI \-E " NUM" "\fR,\fP \-\^\-max\-errors=" NUM |
67 | Select records that have at most | | 70 | Select records that have at most |
68 | .I NUM | | 71 | .I NUM |
69 | errors. | | 72 | errors. |
70 | .TP | | 73 | .TP |
71 | -\fI#\fR | | 74 | -\fI#\fR |
72 | Select records that have at most \fI#\fR errors (\fI#\fR is a | | 75 | Select records that have at most \fI#\fR errors (\fI#\fR is a |
73 | digit between 0 and 9). | | 76 | digit between 0 and 9). |
74 | .SS "Miscellaneous:" | | 77 | .SS "Miscellaneous:" |
75 | .TP | | 78 | .TP |
76 | .BI \-d " PATTERN" "\fR,\fP \-\^\-delimiter=" PATTERN | | 79 | .BI \-d " PATTERN" "\fR,\fP \-\^\-delimiter=" PATTERN |
77 | Set the record delimiter regular expression to | | 80 | Set the record delimiter regular expression to |
78 | .IR PATTERN . | | 81 | .IR PATTERN . |
79 | The text between two delimiters, before the first delimiter, and after | | 82 | The text between two delimiters, before the first delimiter, and after |
80 | the last delimiter is considered to be a record. The default record | | 83 | the last delimiter is considered to be a record. |
| | | 84 | The default record |
81 | delimiter is the regexp "\\n", so by default a record is a line. | | 85 | delimiter is the regexp "\\n", so by default a record is a line. |
82 | .I PATTERN | | 86 | .I PATTERN |
83 | can be any regular expression that does not match the empty string. | | 87 | can be any regular expression that does not match the empty string. |
84 | For example, using | | 88 | For example, using |
85 | .B \-d | | 89 | .B \-d |
86 | "^From " | | 90 | "^From " |
87 | defines mail messages as records in a Mailbox format file. | | 91 | defines mail messages as records in a Mailbox format file. |
88 | .TP | | 92 | .TP |
89 | .BR \-v ", " \-\^\-invert\-match | | 93 | .BR \-v ", " \-\^\-invert\-match |
90 | Select non-matching records instead of matching records. | | 94 | Select non-matching records instead of matching records. |
91 | .TP | | 95 | .TP |
92 | .BR \-V ", " \-\^\-version | | 96 | .BR \-V ", " \-\^\-version |
93 | Print version information and exit. | | 97 | Print version information and exit. |
94 | .TP | | 98 | .TP |
95 | .BR \-y ", " \-\^\-nothing | | 99 | .BR \-y ", " \-\^\-nothing |
96 | Does nothing. This options exists only for compatibility with the | | 100 | Does nothing. |
| | | 101 | This options exists only for compatibility with the |
97 | non-free agrep program. | | 102 | non-free agrep program. |
98 | .TP | | 103 | .TP |
99 | .BR \-\^\-help | | 104 | .BR \-\^\-help |
100 | Display a brief help message and exit. | | 105 | Display a brief help message and exit. |
101 | .SS "Output control:" | | 106 | .SS "Output control:" |
102 | .TP | | 107 | .TP |
103 | .BR \-B ", " \-\^\-best\-match | | 108 | .BR \-B ", " \-\^\-best\-match |
104 | Only output the best matching records, that is, the records with the | | 109 | Only output the best matching records, that is, the records with the |
105 | lowest cost. This is currently implemented by making two passes over | | 110 | lowest cost. |
| | | 111 | This is currently implemented by making two passes over |
106 | the input files and cannot be used when reading from standard input. | | 112 | the input files and cannot be used when reading from standard input. |
107 | .TP | | 113 | .TP |
108 | .BR \-\^\-color ", " \-\^\-colour | | 114 | .BR \-\^\-color ", " \-\^\-colour |
109 | Highlight the matching strings in the output with a color marker. The | | 115 | Highlight the matching strings in the output with a color marker. |
110 | color string is taken from the | | 116 | The color string is taken from the |
111 | .BI GREP_COLOR | | 117 | .BI GREP_COLOR |
112 | environment variable. The default color is red. | | 118 | environment variable. |
| | | 119 | The default color is red. |
113 | .TP | | 120 | .TP |
114 | .BR \-c ", " \-\^\-count | | 121 | .BR \-c ", " \-\^\-count |
115 | Only print a count of matching records per each input file, | | 122 | Only print a count of matching records per each input file, |
116 | suppressing normal output. | | 123 | suppressing normal output. |
117 | .TP | | 124 | .TP |
118 | .BR \-h ", " \-\^\-no\-filename | | 125 | .BR \-h ", " \-\^\-no\-filename |
119 | Suppress the prefixing filename on output when multiple files are | | 126 | Suppress the prefixing filename on output when multiple files are |
120 | searched. | | 127 | searched. |
121 | .TP | | 128 | .TP |
122 | .BR \-H ", " \-\^\-with\-filename | | 129 | .BR \-H ", " \-\^\-with\-filename |
123 | Prefix each output record with the name of the input file where the | | 130 | Prefix each output record with the name of the input file where the |
124 | record was read from. | | 131 | record was read from. |
125 | .TP | | 132 | .TP |
126 | .BR \-l ", " \-\^\-files\-with\-matches | | 133 | .BR \-l ", " \-\^\-files\-with\-matches |
127 | Only print the name of each input file which contains at least one | | 134 | Only print the name of each input file which contains at least one |
128 | match, suppressing normal output. The scanning for each file will | | 135 | match, suppressing normal output. |
129 | stop on the first match. | | 136 | The scanning for each file will stop on the first match. |
130 | .TP | | 137 | .TP |
131 | .BR \-n ", " \-\^\-record\-number | | 138 | .BR \-n ", " \-\^\-record\-number |
132 | Prefix each output record with its sequence number in the input file. | | 139 | Prefix each output record with its sequence number in the input file. |
133 | The number of the first record is 1. | | 140 | The number of the first record is 1. |
134 | .TP | | 141 | .TP |
135 | .BR \-q ", " \-\^\-quiet ", " \-\^\-silent | | 142 | .BR \-q ", " \-\^\-quiet ", " \-\^\-silent |
136 | Do not write anything to standard output. Exit immediately with zero | | 143 | Do not write anything to standard output. |
137 | exit status if a match is found. | | 144 | Exit immediately with zero exit status if a match is found. |
138 | .TP | | 145 | .TP |
139 | .BR \-s ", " \-\^\-show\-cost | | 146 | .BR \-s ", " \-\^\-show\-cost |
140 | Print match cost with output. | | 147 | Print match cost with output. |
141 | .TP | | 148 | .TP |
142 | .BR \-\^\-show\-position | | 149 | .BR \-\^\-show\-position |
143 | Prefix each output record with the start and end offset of the first | | 150 | Prefix each output record with the start and end offset of the first |
144 | match within the record. The offset of the first character of the | | 151 | match within the record. |
145 | record is 0. The end position is given as the offset of the first | | 152 | The offset of the first character of the record is 0. |
| | | 153 | The end position is given as the offset of the first |
146 | character after the match. | | 154 | character after the match. |
147 | .TP | | 155 | .TP |
148 | .BR \-M ", " \-\^\-delimiter\-after | | 156 | .BR \-M ", " \-\^\-delimiter\-after |
149 | By default, the record delimiter is the newline character and is | | 157 | By default, the record delimiter is the newline character and is |
150 | output after the matching record. If | | 158 | output after the matching record. |
| | | 159 | If |
151 | .B \-d | | 160 | .B \-d |
152 | is used, the record delimiter will be output before the matching | | 161 | is used, the record delimiter will be output before the matching |
153 | record. This option causes the delimiter to be output after the | | 162 | record. |
| | | 163 | This option causes the delimiter to be output after the |
154 | matching record. | | 164 | matching record. |
155 | .PP | | 165 | .PP |
156 | With no | | 166 | With no |
157 | .IR FILE , | | 167 | .IR FILE , |
158 | or when | | 168 | or when |
159 | .I FILE | | 169 | .I FILE |
160 | is -, reads standard input. If less than two | | 170 | is -, reads standard input. |
| | | 171 | If less than two |
161 | .IR FILE s | | 172 | .IR FILE s |
162 | are given | | 173 | are given |
163 | .B \-h | | 174 | .B \-h |
164 | is assumed, otherwise | | 175 | is assumed, otherwise |
165 | .B \-H | | 176 | .B \-H |
166 | is the default. | | 177 | is the default. |
167 | .SH DIAGNOSTICS | | 178 | .SH DIAGNOSTICS |
168 | Exit status is 0 if a match is found, 1 for no match, and 2 if there | | 179 | Exit status is 0 if a match is found, 1 for no match, and 2 if there |
169 | were errors. If | | 180 | were errors. |
| | | 181 | If |
170 | .B \-E | | 182 | .B \-E |
171 | or -\fI#\fR is not specified, only exact matches are selected. | | 183 | or -\fI#\fR is not specified, only exact matches are selected. |
172 | .PP | | 184 | .PP |
173 | .I PATTERN | | 185 | .I PATTERN |
174 | is a POSIX extended regular expression (ERE) with the TRE extensions. | | 186 | is a POSIX extended regular expression (ERE) with the TRE extensions. |
175 | .SH "REPORTING BUGS" | | 187 | .SH "REPORTING BUGS" |
176 | Report bugs to the TRE mailing list | | 188 | Report bugs to the TRE mailing list |
177 | .BR "" < tre-general@lists.laurikari.net >. | | 189 | .BR "" < tre-general@lists.laurikari.net >. |
178 | .SH COPYRIGHT | | 190 | .SH COPYRIGHT |
179 | Copyright \(co 2002-2004 Ville Laurikari. | | 191 | Copyright \(co 2002-2004 Ville Laurikari. |
180 | .br | | 192 | .br |
181 | This is free software, and comes with ABSOLUTELY NO WARRANTY. | | 193 | This is free software, and comes with ABSOLUTELY NO WARRANTY. |
182 | You are welcome to redistribute this software under certain | | 194 | You are welcome to redistribute this software under certain |