As with the rest of the grep family, the characters
ell. To avoid these problems, one should always enclose the entire
pattern argument in single quotes, i.e., 'pattern'.
Do not use double quotes (").
When
agrep
is applied to more than one input
file, the name of the file is displayed
preceding each line which matches
the pattern. The filename is not displayed
when processing a single
file, so if you actually want the filename
to appear, use
/dev/null
as a second file in the list.
own:
"the best match contains x errors, there are y matches, Output them? (y/n)"
The best match mode is not supported for standard input, e.g.,
pipeline input.
When the -#, -c, or -l options are specified, the -B option is ignored.
In general, -B may be slower than -#, but not by very much.
ould be preceded by `\\' if they are to be matched as regular
characters. For example, \\^abc\\\\ corresponds to the string ^abc\\,
whereas ^abc corresponds to the string abc at the beginning of a
line.
agrep -2 -c ABCDEFG foo
gives the number of lines in file foo that contain ABCDEFG
within two errors.
agrep -1 -D2 -S2 'ABCD#YZ' foo
outputs the lines containing ABCD followed, within
agrep -5 -p abcdefghij /usr/dict/words
outputs the list of all words containing at least 5 of the first 10
letters of the
habet in order\fR. (Try it: any list starting
with academia and ending with sacrilegious must mean something!)
agrep -1 'abc[0-9](de|fg)*[x-z]' foo
outputs the lines containing, within up to one error, the string
that starts with abc followed by one digit, followed by zero or more
repetitions of either de or fg, followed by either x, y, or z.
agrep -d '^From\ ' 'breakdown;internet' mbox
outputs all mail messages (the pattern '^From\ ' separates mail messages
in a mail file) that contain keywords 'breakdown' and 'internet'.
agrep -d '$$' -1 '
agrep '^agrep'
The following can cause an infinite loop: AUTHORS
Sun Wu and Udi Manber, Department of Computer Science, University of
Arizona, Tucson, AZ 85721. {sw|udi}@cs.arizona.edu.
finds all paragraphs that contain word1 followed by word2 with one
error in place of the blank.
In particular, if word1 is the last word in a line and word2
is the first word in the next line, then the space will be
substituted by a newline symbol and it will match.
Thus, this is a way to overcome separation by a newline.
Note that -d '$$' (or another delim which spans more than one line)
is necessary, because otherwise agrep searches
only one line at a time.
outputs all the examples of the use of agrep in this man pages.
BUGS/LIMITATIONS
Any bug reports or comments will be appreciated!
Please mail them to sw@cs.arizona.edu or udi@cs.arizona.edu
Regular expressions do not support the '+' operator (match 1 or more
instances of the preceding token). These can be searched for by using
this syntax in the pattern:
.sp
.in 1.0i
\&'pattern(pattern)*\fR'
.in
.sp
(search for strings containing one instance of the pattern, followed by 0 or
more instances of the pattern).
agrep
pattern * > out_file.
If the number of matches is high, they may be deposited in
out_file before it is completely read leading to more matches of
the pattern within output_file (the matches are against the whole
directory). It's not clear whether this is a "bug" (grep will do the
same), but be warned.
The maximum size of the
patternfile
is limited to be 250Kb, and the maximum number of patterns
is limited to be 30,000.
Standard input is the default if no input file is given.
However, if standard input is keyed in directly (as opposed to through
a pipe, for example) agrep may not work for some non-simple patterns.
There is no size limit for simple patterns.
More complicated patterns are currently limited to approximately 30 characters.
Lines are limited to 1024 characters.
Records are limited to 48K, and may be truncated if they are larger
than that.
The limit of record length can be
changed by modifying the parameter Max_record in agrep.h.
> DIAGNOSTICS
Exit status is 0 if any matches are found,
1 if none, 2 for syntax errors or inaccessible files.