**************************** AMUS Program Label ****************************** * Filename: EGREP.LIT Date: 30-1-91 * Category: UTIL Hash Code: 376-154-347-436 Version: 1.0 * Initials: AIRS/AM Name: DAVE GREENE * Company: APPLIED INFORMATION RETRIEVAL SYSTEMS Telephone #: 6178991100 * Related Files: * Min. Op. Sys.: AMOSL 1.3 Expertise Level: BEG * Special: Source code is available from AIRS. * Description: GREP string matching utility. * ***************************************************************************** *** Grep And You *** GNU egrep understands the following command line options: -A print lines of context after every matching line -B print lines of context before every matching line -C print 2 lines of context on each side of every match - print lines of context on each side -V print the version number on stderr -b print every match preceded by its byte offset -c print a total count of matching lines only -e search for ; useful if begins with - -f take from the given -h don't display filenames on matches -i ignore case difference when comparing strings -l list files containing matches only -n print each match preceded by its line number -s run silently producing no output except error messages -t assume all input files are in superview format -u convert regular expression to all upper case -v print only lines that contain no matches for the -w print only lines where the match is a complete word -x print only lines where the match is a whole line -y truncate lines wider than the screen Remember to send the output of egrep to a file, you need to add to your command line ">outfile" where outfile is the name of the file you wish output to be directed. Remember that prior to AMOS 2.0, you have to preceed characters that are to be captitalized with a '\'. If the search expression is all upper case, the -u option can be used to indicate upper case only. Note that the entire search string is converted to upper case. If an input file has the '.t' extension, it will be treated as a superview file. If you want to grep on superview files that lack the '.t' extension, use the -t flag in the grep command line. Meta Character Explanation . matches any single character except newline ? postfix operator; preceeding item is optional * postfix operator; preceeding item 0 or more times + postfix operator; preceeding item 1 or more times | infix operator; matches either argument ^ matches the empty string at the beginning of a line $ matches the empty string at the end of a line \< matches the empty string at the beginning of a word \> matches the empty string at the end of a word [chars] match any character in the given class; if the first character after [ is ^, match any character not in the given class; a range of characters may be specified by -; for example, \W (below) is equivalent to the class [^A-Za-z0-9] ( ) parentheses are used to override operator precedence Meta Character Explanation \<1-9> \ matches a repeat of the text matched earlier in the regexp by the subexpression inside the nth opening parenthesis \ any special character may be preceded by a backslash to match it literally (the following are for compatibility with GNU Emacs) \b matches the empty string at the edge of a word \B matches the empty string if not at the edge of a word \w matches word-constituent characters (letters & digits) \W matches characters that are not word-constituent Operator precedence is (highest to lowest) ?, *, and +, concatenation, and finally |. All other constructs are syntactically identical to normal characters. For the truly interested, a comment in dfa.c describes the exact grammar understood by the parser. The options understood by GNU egrep are meant to be (nearly) compatible with both the BSD and System V versions of grep and egrep. The following incompatibilities with other versions of grep exist: the context-dependent meaning of * is not quite the same (grep only) -b prints a byte offset instead of a block offset the \{m,n\} construct of System V grep is not implemented .