-v for reversing the match (display non-matching instead of matching)
-e to specify multiple patterns, matching any one is sufficient
-w to match only at word boundaries, easier to type than the equivalent regexp
-c for displaying the match count rather than the matches
And some that that I use occasionally:
-NUM, -B NUM, -A NUM also show NUM lines around/before/after match
-l to display only the filenames with the matches
-F “fixed” pattern meaning literal match only rather than regexp. Great to avoid having to quote regexp special characters when you don’t need regexp matching
-P for PCRE style regexps
-f to read match patterns from a file
-q quiet, only produce exit status, no output. Useful in shell expressions (scripts, one liners).
-a force treating the input as text (useful to override the binary detection heuristic. mnemonic: ascii)
A few more options that I use pretty much daily:
-v
for reversing the match (display non-matching instead of matching)-e
to specify multiple patterns, matching any one is sufficient-w
to match only at word boundaries, easier to type than the equivalent regexp-c
for displaying the match count rather than the matchesAnd some that that I use occasionally:
-NUM
,-B NUM
,-A NUM
also showNUM
lines around/before/after match-l
to display only the filenames with the matches-F
“fixed” pattern meaning literal match only rather than regexp. Great to avoid having to quote regexp special characters when you don’t need regexp matching-P
for PCRE style regexps-f
to read match patterns from a file-q
quiet, only produce exit status, no output. Useful in shell expressions (scripts, one liners).-a
force treating the input as text (useful to override the binary detection heuristic. mnemonic: ascii)