GRAM_GREP(1)
π gram_grep(1) β the search bestie π
User Commands Β· gram_grep
okay so. you know grep? the icon, the legend, the girl who has been carrying Unix on her back since forever? this is her cooler younger sister. gram_grep π
she searches for PATTERNs in each FILE or on standard input, and she also has a whole grammar-matching side hustle that regular grep could never. no cap.
β¨ NAME β¨
gram_grep β Search for PATTERNs in each FILE or standard input π¦
β¨ SYNOPSIS β¨
gram_grep ([OPTION]... PATTERN)+ [FILE]...
β¨ DESCRIPTION β¨
bestie, here's the vibe: you go hunting for PATTERNs inside every FILE you name, or on standard input if you don't name any. π
PATTERN is, by default, a basic regular expression (BRE). and okay, slight plot twist β that default only applies to the first PATTERN, which is there for grep(1) compatibility. yes, literally only the first one. it's giving "we keep the old friend around for the lore" π
β¨ OPTIONS β¨
π PATTERN SELECTION AND INTERPRETATION
how do you want to read your patterns, queen? pick a lane:
-E,--extended-regexpβPATTERNs are extended regular expressions β¨-F,--fixed-stringsβPATTERNis a string (just vibes, no regex)-G,--basic-regexpβPATTERNs are basic regular expressions π«Ά-P,--perl-regexpβPATTERNis a Perl regular expression π-e,--regexp=PATTERNSβ usePATTERNsfor matching-f,--file=FILEβ takePATTERNs fromFILE-i,--ignore-caseβ ignore case distinctions in patterns and data (so chill of her)--no-ignore-caseβ do not ignore case distinctions (default)-w,--word-regexpβ match only whole words-x,--line-regexpβ match only whole lines
π MISCELLANEOUS
the odds and ends shelf, we love her:
-s,--no-messagesβ suppress error messages (shhh π€«)-v,--invert-matchβ select non-matching text-V,--versionβ display version information and exit--helpβ display help text and exit
π OUTPUT CONTROL
this is where she really shows out. all the little knobs for what actually gets printed:
-m,--max-count=NUMβ stop afterNUMselected lines-b,--byte-offsetβ print the byte offset with output lines-n,--line-numberβ print line number with output lines--line-bufferedβ flush output on every line-H,--with-filenameβ print file name with output lines-h,--no-filenameβ suppress the file name prefix on output--label=LABELβ useLABELas the standard input file name prefix-o,--only-matchingβ show only nonempty parts of lines that match-q,--quiet,--silentβ suppress all normal output--binary-files=TYPEβ assume that binary files areTYPE;TYPEisbinary,text, orwithout-match-a,--textβ equivalent to--binary-files=text-Iβ equivalent to--binary-files=without-match-d,--directories=ACTIONβ how to handle directories;ACTIONisread,recurse, orskip-r,--recursiveβ like--directories=recurse-R,--dereference-recursiveβ likewise, but follow all symlinks π--include=GLOBβ search only files that matchGLOB(a file pattern)--exclude=GLOBβ skip files that matchGLOB--exclude-from=FILEβ skip files that match any file pattern fromFILE--exclude-dir=GLOBβ skip directories that matchGLOB-L,--files-without-matchβ print only names ofFILEs with no selected lines-l,--files-with-matchesβ print only names ofFILEs with selected lines-c,--countβ print only a count of selected lines perFILE-T,--initial-tabβ make tabs line up (if needed)-Z,--nullβ print 0 byte afterFILEname
π¦ CONTEXT CONTROL
so you can see the ~vibes~ around your match:
-B,--before-context=NUMβ printNUMlines of leading context-A,--after-context=NUMβ printNUMlines of trailing context-C,--context=NUMβ printNUMlines of output context-NUMβ same as--context=NUM--group-separator=SEPβ printSEPon line between matches with context--no-group-separatorβ do not print separator for matches with context--color[=WHEN],--colour[=WHEN]β use markers to highlight the matching strings;WHENisalways,never, orautoπ
π GRAM_GREP SPECIFIC SWITCHES
okay THIS is the main character section. the stuff plain grep could never:
--checkout=CMDβ checkout command (include$1for pathname)--config=CONFIG_FILEβ search using config file--display-whole-matchβ display a multiline match--dumpβ dump DFA regexp--dump-argvβ dump command line arguments--dump-dotβ dump DFA regexp in DOT format--exec=CMDβ Executes the supplied command--extend-searchβ extend the end of the next match to be the current match--flex-regexpβPATTERNis a flex style regexp--force-writeβ if a file is read only, force it to be writable--if=CONDITIONβ make search conditional--invert-match-allβ only match if the search does not match at all-N,--line-number-parensβ print line number in parenthesis with output lines--perform-outputβ output changes to matching file-p,--print=TEXTβ printTEXTinstead of line of match--print-script=SCRIPTβ print result ofSCRIPTinstead of line of match--replace=TEXTβ replace match withTEXT--replace-script=SCRIPTβ replace match with result ofSCRIPT--return-previous-matchβ return the previous match instead of the current one--shutdown=CMDβ command to run when exiting--startup=CMDβ command to run at startup--summaryβ show match count footer--utf8β in the absence of a BOM assume UTF-8-W,--word-list=PATHNAMEβ search for a word from the supplied word list--writableβ only process files that are writable
β¨ FILES β¨
a configuration file can be supplied using --config=CONFIG_FILE. π
π§ CONFIG FILE FORMAT
<grammar directives>
%%
<grammar>
%%
<regexp macros>
%%
<regexes>
%%
πΈ GRAMMAR DIRECTIVES
%capturesβ (parenthesis in grammars will be treated as captures)%consumeβ (list tokens that are not to be reported as unused)%option caseless%token%left%right%nonassoc%precedence%start%x
π« SCRIPTING GRAMMAR
cmd: Name '=' ret_function
| Name '+=' ret_function
| 'erase' '(' Index [ ',' Index ] ',' ret_function ')'
| 'erase' '(' Index '.' first_second ','
Index '.' first_second ',' ret_function ')'
| 'insert' '(' Index [ '.' 'second' ] ',' ret_function ')'
| 'match' '=' Index
| 'match' '=' 'substr' '(' Index ',' UInt ',' UInt ')'
| 'match' '+=' Index
| 'match' '+=' 'substr' '(' Index ',' UInt ',' UInt ')'
| 'print' '(' ret_function ')';
| 'replace' '(' Index [ ',' Index ] ',' ret_function ')'
| 'replace' '(' Index '.' first_second ','
Index '.' first_second ',' ret_function ')'
first_second: 'first'
| 'second';
ret_function: String
| Name
| Index
| 'capitalise' '(' ret_function ')'
| 'format' '(' ret_function format_params ')'
| 'replace_all' '(' ret_function ',' ret_function ','
ret_function ')'
| 'system' '(' ret_function ')'
| 'tolower' '(' ret_function ')'
| 'toupper' '(' ret_function ')';
format_params: %empty
| format_params ',' ret_function;
π SCRIPTING TOKENS
Index: $[1-9]\d*
Name: [A-Z_a-z][-\w]*
String:
'(''|[^'])*'
UInt: \d+
π«Ά --if SYNTAX
regex_search($n, 'regex'){ || regex_search($n, 'regex')}
tolower($n);
toupper($n);
β¨ EXAMPLE β¨
%token RawString String
%%
list: String { match = substr($1, 1, 1); };
list: RawString { match = substr($1, 3, 2); };
list: list String { match += substr($2 1, 1); };
list: list RawString { match += substr($2, 3, 2); };
%%
ws [ \t\r\n]+
%%
\"([^"\\\r\n]|\\.)*\" String
R\"\((?s:.)*?\)\" RawString
'([^'\\\r\n]|\\.)*' skip()
{ws}|"//".*|"/*"(?s:.)*?"*/" skip()
%%
β¨ NOTES β¨
ngl bestie, this one's actually useful: you can pipeline searches by using multiple switches. the searches are run in the order they occur on the command line. β
β¨ EXAMPLES β¨
gram_grep -i "hello world" menu.h main.c
look at her go. lowercase hello world, two files, chef's kiss π
β¨ SEE ALSO β¨
grep(1) β the OG. respect her name. π«Ά
that's the whole page, bestie π this one's from the gram_grep manual, User Commands edition, dated April 2026. mwah, go search something iconic β¨π
π¦ where this page comes from
- epel 10: gram_grep 0.10.3-1.el10_3 Β· BSL-1.0
- fedora 43: gram_grep 0.10.2-4.fc43
- fedora 43: gram_grep 0.10.3-1.fc43 Β· BSL-1.0
- fedora 44: gram_grep 0.10.2-5.fc44
- fedora 44: gram_grep 0.10.3-1.fc44 Β· BSL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms