File and Path Selection
Process all files as text. Beware of binary output interpreted as commands.
Skip files whose base names match glob.
--exclude but get list of globs from file
Skip directories that match. Directories will also not be recursed.
Don't match binary files
Search only for files matching glob.
Globs can use *, ?, and [...] as wildcards. Use \ as escape. Enclose multiples in curly braces, e.g.
Use line buffering on output. Can reduce performance.
Treat file(s) as binary.
Treat lines as zero byte terminated instead of newline
0 - Selected lines are found
1 - Selected lines are not found
2 - Error occurred (unless a match is found and errors are ignored with the
Extended regular expressions (ERE)
Basic regular expressions (BRE)
Perl regular expression (experimental?)
Used to specify multiple patterns or protect patterns starting with "-"
Input file for patterns, one per line
Whole word matches only
Match whole line only
Match any character
[ ... ]
Match character list.
Use ^ to invert match.
Specify ranges with hyphen (
Ranges can also be specified using a character class, e.g.
number[[:digit:]]. Valid character classes are: [:alnum:], [:alpha:], [:cntrl:], [:digit:], [:graph:], [:lower:], [:print:], [:punct:], [:space:], [:upper:], and [:xdigit:]
?, *, +
Repetition operators indicating at most once, zero or more, or at least once, respectively.
Match exactly n times.
Match at least n times.
Match 0 to m times.
Match n to m times.
Match beginning or end of a word, respectively.
Match both beginning and end of the word. \B matches the opposite.
Match word character, aka
[[:alnum:]]. \W matches the opposite.
Backreference to previously matched group where
n is a single digit.
The above represents extended regular expression syntax. For basic syntax, you must escape
Print 0-based byte offset of match within file
Print the file name for each match (default)
Hide filename from output
Prefix output with line number
Ensure first line of content is tab-aligned for readability
Output a zero byte after file names
Count number of lines
With no WHEN it will show colors when it's the final command in the pipe. WHEN is never, always, or auto.
Show only names of files that do NOT match
Show only names of matching files
Max number of lines to read from any file
Output only the matching text
Quiet, no output
Suppress error messages for missing or unreadable files
Print NUM lines of trailing context after match
Print NUM lines of lead context before match
Print NUM lines of context
ls -rt * | xargs grep -e 'searchtext'
Searches through files in chronological order.