grep is the command of the Linux Chinese editing class to select the desired text content
Main format: grep [option] "PATTERN" FILENAME
Option:-I ignores case
-O displays only the characters that match
-V Reverse display (shows rows not matched to)
--color to display matching characters in color notation
"PATTERN": Supports RegExp (regular expression)
1, character matching:
. : Matches one character
[]: Character matching interval example: [A-z]
[^]: Character matching reverse interval example: [^a-z]
2. Number of character matches
*: Any number of common usage:. *: Any number of characters
\?: 0 or 1 times
\{m,n\}: At least m times, up to N times
\{1,\} at least 1 times
\{0,3\} 0-3 plays
3, anchor character
^: Anchoring the beginning of the line
$: Anchor Line End
\<: Anchor Word first
\>: Anchor ending
4. Grouping
\(.. \): Group Overall match for example: \ (ab\): With AB as a whole
Latter references: \1 \2 \3 characters in a group
\1: Represents a group in a forward reference to the first (to corresponding)
\2: Represents a grouping in a second "(to corresponding") reference
This article is from the "7792395" blog, please be sure to keep this source http://7802395.blog.51cto.com/7792395/1616736
Summary of common usage of grep in Linux