display | more...

From the authors' notes:

AGREP is a powerful tool for fast searching a file or many files for a string or regular expression, with approximate matching capabilities and user-definable records. It was developed 1989-1991 by Udi Manber and Sun Wu at the University of Arizona and many others. AGREP is similar to egrep (or grep or fgrep), but it is much more general and usually faster.

agrep, also known as approximate grep, is a unix utility developed by Udi Manber and Sun Wu at the University of Arizona. It is similar to grep and egrep in that it accepts as input a particular search term and a list of files, and it finds all matches for that search term in the files given.

Internally, agrep uses the Shift-And method for its string matching capabilities, with one twist: it allows for errors by creating a number of arrays, each accounting for more errors than the previous one (the original Shift-And method calculated only the first array, which accounted for no errors). This revised version of the method repeats the calculation process, only accounting for errors by using an OR operand in calculating the arrays. These arrays are generated when you run the program, as they are based on the files you are searching for. To understand this better, read through the Shift-And method.

Using agrep is quite easy. A simple example of usage is as follows:

     agrep Banana *

This command would search through every file in the current directory for the word Banana; in this it works exactly like grep and egrep. Another example of usage is the powerful -ia option, which means that it automatically searches for umlauts and accent marks in addition to the letters you give. For example,

     agrep -ie resume *

would search for every variation on resume, with accent marks over each e and without them, and even with or without an umlaut over the u's and e's.

The real power of agrep, and what sets it apart from the other grep utilities, is the very powerful -# option, where # is a number. This tells how many errors that your search string can have and still return a match. For example,

     agrep -1 resume *

returns a match for every imaginable version of the word resume with one error, such as an insertion, a deletion, or a mismatch. Naturally, this takes a bit longer than a normal run of agrep, but options up to -3 usually take place in the blink of an eye. This ability comes in handy when you are dealing with common misspellings and mistypings; agrep -1 and agrep -2 have solved countless problems over the years. agrep has many more options as well, but these are the ones that have found daily use in my workplace.

agrep is very quick, performing most searches seemingly instantaneously. It is available for virtually every unix and Linux platform, as well as for versions of Microsoft Windows. The program is easily available at several internet locations; a good place to start looking for it is the agrep homepage at www.tgries.de/agrep/.

Log in or register to write something here or to contact authors.