FreeBSD/Linux
grep -E (same as `egrep', --extended-regexp)
ex)
grep -E '^(foo|bar)' file.txt
same as
grep '^\(foo\|boar\)'
In basic regular expressions the metacharacters ?, +, {, |, (, and ) lose their
special meaning;
instead use the backslashed versions \?, \+, \{, \|, \(, and \).
-E, --extended-regexp
-G, --basic-regexp
-i, --ignore-case
-q, --quiet, --silent
-n, --line-number /*** good idea ***/
Prefix each line of output with the line number within its
input file.
-r, --recursive
Read all files under each directory, recursively; this is
equivalent to the -d recurse option.
-v, --invert-match
-x, --line-regexp
Select only those matches that exactly match the whole line.
[:alnum:],
[:alpha:],
[:cntrl:],
[:digit:],
[:graph:],
[:lower:],
[:print:],
[:punct:],
[:space:],
[:upper:],
[:xdigit:]
For example, [[:alnum:]] means [0-9A-Za-z]
A regular expression may be followed by one of several repetition
operators:
? The preceding item is optional and matched at most once.
* The preceding item will be matched zero or more times.
+ The preceding item will be matched one or more times.
{n} The preceding item is matched exactly n times.
{n,} The preceding item is matched n or more times.
{n,m} The preceding item is matched at least n times, but
not more than m times.
EOF
|