Command Line

Grouse Grep implements most of the basic features implemented by GNU Grep, but does not support most of the advanced features. Features missing include before/after context reporting, extended regular expressions and a full set of directory recursion options.

Regular expression components

Grouse Grep supports these RE components:

literal Most characters merely match themselves (literals)

\literal \ escapes "special" characters to defeat their special meaning

. Match any character, except LF (or CR /LF if -R given)

^ Anchor search to the start of the line

$ Anchor search to the end of the line

[0-9aeiou] Match any member of class

[^0-9aeiou] Match all but the characters specified in the class

[]] Place " ]" first in class if it's a class member (otherwise it closes the class spec)

[aeiou-] Place " -" last in class if it's a class member (otherwise it's a range specifier)

[x^] Place " ^" anywhere but first to stop the "all but" meaning

[[:alnum:]] Match any alphabetic or numeric value; also [:alpha:] , [:cntrl:], [:digit:], [:graph:] , [:lower:], [:print:], [:punct:] , [:space:], [:upper:], [:xdigit:]

\< Match start-of-word boundary

\> Match end-of-word boundary

\b Match word boundary

\B Match word nonboundary

* Match previous RE component 0 or more times

+ Match previous RE component 1 or more times

? Match previous RE component 0 or 1 times (make element optional)

GNU-Compatible options

-b Display byte offset

-c Count matching lines

-e regexp Use next word as the RE to search

-E Operate like " egrep" (support extended REs)

-f file Read RE to search from file

-F Operate as " fgrep" (fast and fixed-text searches)

-G Operate as " grep" (default)

-h Suppress filename prefix if searching multiple files

-i Make alphabetic matching case-insensitive

-l Display filenames only for matching files

-L Display filenames only for nonmatching files

-n Prefix matching text with line numbers

-r Recurse directories

-V Display program version

-v Invert match sense

-w Match words: edges of match must be nonwords

-x Only match entire lines

Additional search options

-H Highlight matching text

-R Treat CR /LF as a line terminator as well as LF

-W Match words as per -w, but also restrict " ." and " [^...]" to word chars

Debugging options

-C Display compiled RE codes

-D Display state tables

-M c Mark the match output with character c (for test rig)

-O optimisations Turn on or off various optimisations

-T trace Configure or query Tracery

Optimisation options

Within the -O switch, the following specifiers are available:

A Enable approximate matching

a Disable approximate matching

B Use Tuned Boyer-Moore instead of STBM

b Don't use TBM instead of STBM

E Search for easiest part of RE first

e Don't search for easiest part first

S Enable optimisations that skip bytes

s Disable optimisations that skip bytes

T Use Self-Tuning Boyer-Moore search if applicable

t Don't use STBM (or TBM) for BM-style searches

Tracery options

Tracery needs to be compiled in for the -T switch to work (usually via #define TRACERY_ENABLED 1 )-- see the macro CPPDEBUGS in the Makefile which has a speed-optimisation version and a trace/debug version. GGrep will issue a short warning if Tracery hasn't been compiled in to GGrep.c.

The modules and aspects of program available for tracing will grow over time. Use the following options to query what Tracery knows about (you may need to use quotes to protect ? and * from the shell):

-T? Display a short table of module names together with the flags supported by each module

-T?spec Display more information about modules matching spec (glob-style wildcards)

-T?* Display detailed information about all Tracery objects and flags

Currently the following modules are supported under Tracery:

s: Scanner
         B        Trace  buffer
         b        Ignore buffer
         S        Trace  scanner
         s        Ignore scanner
         M        Trace  matcher
         m        Ignore matcher
         D        Trace  directory
         d        Ignore directory

m: Matcher
         A        Trace  actions
         a        Ignore actions
         C        Trace  control
         c        Ignore control
         S        Trace  startup
         s        Ignore startup

f: FastFile
         E        Trace  entry
         e        Ignore entry
         B        Trace  buffer
         b        Ignore buffer
         F        Trace  feedover
         f        Ignore feedover

For example, to watch all aspects of FastFile's operation, use:

        ggrep -Tf

To watch Scanner's buffer handling and Matcher's actions, use:

        ggrep -Ts(B),m(A)

And to turn on traces for everything, use:

        ggrep '-T*'