File: agrep.1

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