grep :
Searches for text based on pattern (mode) and displays lines of text that conform to the pattern, without modifying the original file.
Usage: grep [options] ' pattern '/file #也可以利用管道进行匹配
-I ignore ignoring case
--colour the matched string with a color.
-V reverse lookup, showing rows that do not match pattern
-O displays only strings that are matched by the pattern
Regular Expressions REGular expressionWork in greedy mode and try to match as much as possible.
Meta characters:
. : Matches any single character
[]: matches any single character within the range
[:d Igit:] number [: lower:] lowercase letter [: Upper:] Uppercase [:p UNCT:] punctuation [: space:] space [: Alpha:] All characters [: Alnum:] All letters and numbers
Usage: [[:d Igit:]]
[^]: matches any single character outside the range
number of matching characters:
*: matches the preceding character any time (including 0 times)
. *: Any character of any length
\? : matches the preceding character 1 or 0 times, generally add \
\{m,n\}: Matches the preceding character at least m times, up to N times.
\{1,\}: Matches the preceding character at least 1 times
Location Anchoring:
^: Anchor the beginning of the line, any content after this character must appear at the beginning of the line
$: Anchor Line End
^$: Blank Line
\b or \<: Any character following this character must appear as the header of the word
\b or \>: Any character preceding this character must appear as the tail of the word
Grouping
\ (\) usage difference: ab* \ (ab\) *
Can back reference: he love his lover
She like her liker
He like his lover
\1: Represents the invocation of the first opening parenthesis and all the contents of the corresponding closing parenthesis.
\2: ...
The Linux base command grep