usageglark is based on grep, and is nearly 100% compatible in both its input and output. Input: glark accepts the same input as grep, and nearly all of the same options. However, glark accepts Perl-compatible regular expressions and many more input options. Output: By default glark highlights the text that matched the pattern, using ANSI escape sequences, and it also highlights the names of matching files. A --grep option is supported, so that glark produces the same output as grep does. This option is implicitly activated when the EMACS environment variable is set; thus, glark supports running under Emacs. The man page is available online. examplessimple word matchingTo search for "format" in the local .h files. % glark format *.h
case insensitive word matchingTo search for "format", without regard to case. % glark -i format p*.h
context around matchTo produce 6 lines of context around any match for "format". % glark -6 format i*.h
grep-like output formatTo search for "print", producing output in the grep format. Note that this may be useful for being invoked from Emacs. % glark --grep print *.h complex expressionsTo search for either "printf" or "format". % glark -o format print p*.h
To search for both "printf" or "format", within 4 lines of each other. % glark -a 4 printf format *.c *.h To find "distance") of "#define\s+dTHR". % glark -a -1 '#define\s+YIELD' '#define\s+dTHR' *.h
To search for both "printf" or "format", on the same line("within 0 lines of each other"). Three lines of context are displayed around any matches. % glark -3 -a 0 printf format *.c
combining optionsIn order of the options:) Produce 8 lines of context aroundcase insensitive matches of ("phtx" within 2 lines of '...') within 15 lines of (either "va_\w+t" or "die"). % glark -8 -i -a 15 -a 2 pthx '\.\.\.' -o 'va_\w+t' die *.c
complex combinationLook for within 2 lines:
either:
within 2 lines:
PL_sub\w+
and
Isub_generation
or
PERL_CALLCONV)
and
either:
/\bLEX_\w+;/
or
lex_\w+
% glark --explain -3 \
-a 2 \
-o \
-a 0 \'PL_sub\w+\' Isub_generation \
PERL_CALLCONV \
-o \'/\bLEX_\w+;/\' \'lex_\w+\' \
*.c *.h
useful one-linersGet list of targets in Ant build file. % glark -g --extract-matches 'target\s+name="(test\-.*?)"' build.xml |
|







