1. grep is a powerful text search tool that uses regular expressions to match.
Format is: Gerp option ' script ' file
2, Regular expression:
(1) of which characters: +,. , (), |,{}.
In datum mode: The meaning of ordinary characters, the need for escape \.
In extended mode: Take special meaning.
(2) Character class:
. : Matches any one by one characters.
[]: Matches any one by one characters within [].
[-]: any one by one characters in the match range.
[^-]: matches any one by one characters except this range.
[--]: matches any one by one characters in both ranges.
(3) Quantity qualifier:
。 : matches the character before it o/1 times.
+: Matches the preceding character 1/multiple times.
*: matches the preceding character 0/multiple times.
{n}: matches the preceding character N times.
{N,}: matches the preceding character at least n times.
{, n}: matches the characters before it up to N times. I can't use it on my computer.
{n,m}: matches the preceding character between n~m times.
(4) Position qualifier:
^: Matches the beginning of the line.
$: Matches the end of the line.
\<: Match the position where the word is opened.
\>: A position that matches the end of a word.
\b: Matches the start or end of a word.
\b: Matches the position of the beginning or end of a word (the middle position of the word).
3, grep options:
(1)-e: Supports extension of regular expressions. grep defaults to the baseline mode.
(2)-r: Recursive search file.
(3)-O: Outputs only the results that match.
(4)-V: Flip match, that is, the output does not match.
(5)-C: Output matching to a total of a few.
(6)-L: Output matching files.
(7)-I: Ignores case matching.
(8)-N: The line number is also output.