Linux Text Search tool grep
grep function: Search for text based on patterns and display lines of text that conform to the pattern
Pattern: The matching condition of the wildcards regular of the expression with the text character
1 wildcard characters:
*: Any character of any length
?: any single character
[]: matches any single character within the specified range
[^]: contrary to []
2 Regular Expressions:
Metacharacters
.: Matches any single character
*: Number of matches (working in greedy mode, as long as possible),
Match any of its preceding characters
. *: Any character of any length
\?: Match its preceding character 1 or 0 times
\{m,n\}: Matches the preceding character at least m times, up to N times
\{1,\}: Match its preceding characters 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, any content in front of this character must appear at the end of the row
^$: Blank Line
\< or \b: Any character following it must appear as the header of the word
\> or \b: Any character preceding it must appear as the tail of the word
Group
\ (string\): string as a set of characters, a whole, for a back reference
Back to reference
\1: Refers to the first opening parenthesis and all the contents of the corresponding closing parenthesis
\2
\3
grep Basic usage:
grep [OPTIONS] PATTERN [FILE ...]
OPTIONS
-I: Ignore case
--color: descriptor color of the searched word
-V: Show rows that are not matched by the pattern
-O: Displays only the string that is matched to
-A #: Indicates the line to which grep matches and the # line after it
-B #: Indicates the line to which grep matches and the previous # line
-C #: Indicates the line to which grep matches and the # lines before and after
-e: Match extended regular expression
Extended Regular Expression Egrep
Number of Matches
+: Match the characters in front of it at least 1 times
Group
(): In parentheses as a whole
This article is from the "surgery industry has specialized" blog, please be sure to keep this source http://fuvip.blog.51cto.com/9276123/1981118
Linux Text Search tool grep