tgrep(1)

NAME
tgrep - A multi-threaded version of grep with new features.

SYNOPSIS
tgrep <options> pattern <{file/dir}>...

DESCRIPTION
tgrep supports all of grep(1) options except for the -w option. It also has a number of custom options not supported by grep(1)

tgrep will supply three different usage messages depending on the arguments you pass to it to get more information. The first is the option usage, which can be viewed by starting tgrep with no option. The second is the usage for tgrep regular expression language, which can be used by running tgrep with the -Z option. The last usage message is avaliable only if tgrep was build with DEBUG turned on. If this is the case, starting tgrep with the -d0 (zero) option will display the usage on the different levels of debug information tgrep will display.

Tgrep will search all directories and all files in the named directories on the command line for a literal string, or a regular expression string. tgrep will search recursively down through the sub-directories. The same type of search could be performed by using the command:

find . -type f -exec grep <pattern> /dev/null {} \;

or using tgrep:

tgrep <pattern> .

If you do not specify a directory or file name on the command line, the current working directory is added for you (DOT). All files in the current directory and all files in all sub-directories below . (dot) will be searched.

Tgrep supports two different pattern matching engines. The default is a literal pattern matching algorithm called "Boyer-Moore". This is used for fast literal string matching only. Tgrep supports regular expression searching also. With the -e option set, "Boyer-Moore" is not used, in place of it, a PD regular expression engine is used.

OPTIONS (grep(1) like)
-b Show block count. Block size is 512 bytes.
-c Print only a line count.
-h Do not print the file name(s).
-i Case insensitive search.
-l Print file name only.
-n Print the line number with the line.
-s Suppress error messages.
-v Print all but matching lines.

OPTIONS (Tgrep only)
-r Do not search for files in all sub-directories.
-C Show continued lines. Great for Makefile searches. ("\")
-p File name regexp pattern. (Quote it).
-P Show progress. -P1 prints a DOT on stderr for each file it finds, -P10 prints a DOT on stderr for each 10 files it finds, etc...
-e Regular expression search. More then one -e option is supported.
-B Limit the number of threads to TGLIMIT (see ENVIRONMENT below).
-S Print thread stats when done.
-Z Print help on the regexp used.

OPTIONS (debug only)
-d <levels> Print debug messages as tgrep is running to show what thread is performing what operation. -d0 (zero) will print debug usage.
-f # Stop tgrep from using "#" (number) of file descriptors. Tgrep normally will uses all the file descriptors the user has avaliable, but if tgrep is run under debugger control, you need to reserve some.

REGEXP LANGUAGE
Tgrep supports a custom regular expression language write by Marc Staveley of Staveley.com. At the time tgrep was first written, libgen was not MT-SAFE, so the systems regular expression functions could not be used. Marc's regular expression engine supports most if not all the normal expressions, and some unique ones.

meta-chars:
    . - match any character.
    * - match 0 or more occurrences of pervious char.
    + - match 1 or more occurrences of pervious char.
    ^ - match at beginning of string.
    $ - match end of string.
    [ - start of character class.
    ] - end of character class.
    ( - start of a new pattern.
    ) - end of a new pattern.
    @(n)c - match <c> at column <n>.
    | - match either pattern.
    \ - escape any special characters.
    \c - escape any special characters.
    \o - turn on any special characters.

To use the "or" operator, i.e.
tgrep -e '(pat1)|(pat2)' file ...
And you can have up to 10 -e options on the same command line.

ENVIRONMENT
TGLIMIT Set the maximum number of threads tgrep will start at any one time. This will limit the amount of resources tgrep will use on the system. TGLIMIT is ignored if the -B option is NOT set on the command line.

FILES
NONE

NOTES

DIAGNOSTICS
Some of the "grep like" options do not behave exactly like grep(1). This is why they are called "grep like".

EXAMPLES
To search all files from the current directory down, for the target string foobar run:

tgrep foobar

To search all files from the current directory down, for the target strings foobar or bizbar run:

tgrep -e '(foobar)|(bizbar)'
or
tgrep -e 'foobar' -e 'bizbar' .

To search all README files in the current directory and all sub-directories for the strings boobar or foobar run:

tgrep -p '^README$' -e '[bf]oobar'

If the "$" char was omitted from the -p option, then file names like README.first, READMENOW, etc would also be searched.

To search all man page directories for a string of foobar, run:

tgrep foobar /usr/man /usr/local/man /opt/man

To search for the continued line SRC= in all Makefile (or makefile, makefile.master, etc) from the current directory and down, run:

tgrep -p '^[Mm]akefile' -C -e '^SRC.*='

The above command would find and display lines that look like:

SRC = \
    foobar.c \
    main.c \
    lastfile.c

AUTHOR
Ron Winacott    Email : Ron.Winacott@Canada.sun.com