agrep (approximate grep) is a fuzzy string searching program, developed by Udi Manber and Sun Wu between 1988 and 1991, for use with the Unix operating system. It was later ported to OS/2, DOS, and Windows. It selects the best-suited algorithm for the current query from a variety of the known fastest (built-in) string searching algorithms, including Manber and Wu's bitap algorithm based on Levenshtein distances. agrep is also the search engine in the indexer program GLIMPSE. It is free for private and non-commercial use only, and belongs to the University of Arizona. Agrep is almost awk-like in its ability to search records, instead of just lines. A record is by default a line, but it can be user-defined with the -d (for delimiter) switch. For example, from the agrep README file: "agrep -d '^From ' 'pizza' mbox" outputs all mail messages that contain the keyword "pizza". Another example: "agrep -d '$$' pattern foo" will output all paragraphs (separated by an empty line) that contain pattern. Unlike plain grep, agrep also manages multiple patterns with AND (or OR) logic queries. For example: "agrep -d '^From ' 'burger,pizza' mbox" outputs all mail messages containing at least one of the two keywords (, stands for OR). "agrep -d '^From ' 'good;pizza' mbox" outputs all mail messages containing both keywords. A more recent agrep is the command-line tool provided with the TRE regular expression library. TRE agrep is more powerful than Wu-Manber agrep since it allows weights and total costs to be assigned separately to individual groups in the pattern. It can also handle Unicode. Unlike Wu-Manber agrep, TRE agrep is licensed under the GNU LGPL.
External links
- Wu-Manber agrep for Unix
- Wu-Manber agrep for DOS, Windows and OS/2 home page
- cgrep a command line approximate string matching tool
- nrgrep a command line approximate string matching tool
- TRE regexp matching package
- Agrep - Christoph's Personal Wiki


