[BACK]Return to agrep.1 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / external / bsd / tre / bin

File: [cvs.NetBSD.org] / src / external / bsd / tre / bin / agrep.1 (download)

Revision 1.4, Fri Jun 10 08:03:46 2016 UTC (4 years, 1 month ago) by wiz
Branch: MAIN
CVS Tags: prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-9-base, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, is-mlppp-base, is-mlppp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, HEAD
Changes since 1.3: +2 -2 lines

Bump date for -r.

XXX: this file has no license.

.\" $NetBSD: agrep.1,v 1.4 2016/06/10 08:03:46 wiz Exp $
.Dd June 10, 2016
.Nm agrep
.Nd print lines approximately matching a pattern
.Op options
.Ar pattern
.Op files
Searches for approximate matches of
.Ar pattern
in each
or standard input.
.Ss Regexp selection and interpretation
.Bl -tag -width 10n
.It Fl e Ar pattern , Fl Fl regexp= Ns Ar pattern
as a regular expression; useful to protect patterns beginning with
.Sq - .
.It Fl i , Fl Fl ignore-case
Ignore case distinctions (as defined by the current locale) in
.Ar pattern
and input files.
.It Fl k , Fl Fl literal
.Ar pattern
as a literal string, that is, a fixed string with no special
.It Fl w , Fl Fl word-regexp
.Ar pattern
to match only whole words.
.Dq 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
.Em must
surround the match; they cannot be counted as errors.
.Ss Approximate matching settings
.Bl -tag -width 10n
.It Fl Ns Ar #
Select records that have at most
.Ar #
.Ar ( #
is a digit between 0 and 9).
.It Fl D Ar num , Fl Fl delete-cost= Ns Ar num
Set cost of missing characters to
.Ar num .
.It Fl E num , Fl Fl max-errors= Ns Ar num
Select records that have at most
.Ar num
.It Fl I Ar num , Fl Fl insert-cost= Ns Ar num
Set cost of extra characters to
.Ar num .
.It Fl S Ar num , Fl Fl substitue-cost= Ns Ar num
Set cost of incorrect characters to
.Ar 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.
.Ss Miscellaneous
.Bl -tag -width 10n
.It Fl d pattern , Fl Fl delimiter= Ns Ar pattern
Set the record delimiter regular expression to
.Ar 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
.Dq \en ,
so by default a record is a line.
.Ar pattern
can be any regular expression that does not match the empty string.
For example, using
.Fl d Ar \"^From \"
defines mail messages as records in a Mailbox format file.
.It Fl Fl help
Display a brief help message and exit.
.It Fl r , Fl Fl recursive
If a directory is given as one of the command line arguments,
look in every directory entry in the subdirectory, recursively.
.It Fl V , Fl Fl version
Print version information and exit.
.It Fl v , Fl Fl invert-match
Select non-matching records instead of matching records.
.It Fl y , Fl Fl nothing
Does nothing.
This options exists only for compatibility with the
non-free agrep program.
.Ss Output control
.Bl -tag -width 10n
.It Fl B , Fl Fl 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.
.It Fl Fl color , Fl Fl colour
Highlight the matching strings in the output with a color marker.
The color string is taken from the
environment variable.
The default color is red.
.It Fl c , Fl Fl count
Only print a count of matching records per each input file,
suppressing normal output.
.It Fl H , Fl Fl with-filename
Prefix each output record with the name of the input file where the
record was read from.
.It Fl h , Fl Fl no-filename
Suppress the prefixing filename on output when multiple files are
.It Fl l , Fl Fl 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.
.It Fl M , Fl Fl delimiter-after
By default, the record delimiter is the newline character and is
output after the matching record.
.Fl d
is used, the record delimiter will be output before the matching
This option causes the delimiter to be output after the
matching record.
.It Fl n , Fl Fl record-number
Prefix each output record with its sequence number in the input file.
The number of the first record is 1.
.It Fl q , Fl Fl quiet , Fl Fl silent
Do not write anything to standard output.
Exit immediately with zero exit status if a match is found.
.It Fl s , Fl Fl show-cost
Print match cost with output.
.It Fl Fl show-position
Prefix each output record with the start and end offset of the first
match within the record.
The offset of the first character of the record is 0.
The end position is given as the offset of the first
character after the match.
With no
.Ar file ,
or when
.Ar file
.Dq - ,
reads standard input.
If less than two
.Ar files
are given
.Fl h
is assumed, otherwise
.Fl H
is the default.
.Dl agrep \-2 optimize foo.txt
outputs all lines in file
.Pa foo.txt
that match
.Dq optimize
within two errors.
E.g. lines which contain
.Dq optimise ,
.Dq optmise ,
.Dq opitmize
all match.
Exit status is 0 if a match is found, 1 for no match, and 2 if there
were errors.
.Fl E
.Fl Ns Ar #
is not specified, only exact matches are selected.
.Ar pattern
is a POSIX extended regular expression (ERE) with the TRE extensions.
Report bugs to the TRE mailing list
.Aq Mt tre-general@lists.laurikari.net .
Copyright \(co 2002-2004 Ville Laurikari.
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.