Regular Expressions (REGGXP):
A regular expression is a filtering logic (that is, a pattern) of a string. is a pattern written by metacharacters and normal characters, in which the metacharacters do not represent the meaning of the character itself, but are used to express control or to function as a wildcard, and can be divided into two types:
1. Basic Regular Expressions
2. Extending the regular expression
Grep:
A text Search tool to complete text filtering based on basic regular expressions
Egrep
A text Search tool to complete text filtering based on extended regular expressions
Regular Expressions Common meta-character meanings :
Listing 1: For basic regular expressions
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5C/26/wKioL1UbwIXhtB0tAANPTRGO05M028.jpg "title=" 1.png " alt= "Wkiol1ubwixhtb0taanptrgo05m028.jpg"/>
Listing 2: For extended regular expressions
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5C/26/wKioL1UbwRniu3DtAAMMzyuqenY478.jpg "title=" 2.png " alt= "Wkiol1ubwrniu3dtaammzyuqeny478.jpg"/>
Note: the patterns in the grouping, the characters that are matched during a specific match, can be memorized by grep (stored in the built-in variables, these variables are \1,\2,... ), so that it can also be referenced
\1: Reference, from left to right in a pattern, matched by the first opening parenthesis and the pattern in the right parenthesis corresponding to it
\2: Reference, from left to right in a pattern, matched by the second opening parenthesis and the pattern in the right parenthesis corresponding to it
grep:
The Text Search tool searches the target file on a per-line basis according to the user-specified text pattern and displays the rows that can be matched to.
Use format:
grep [OPTIONS] PATTERN [FILE ...]
--color[=when],--colour[=when]   &NBSP,
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/0E/wKioL1UgpL3AKwt7AAB10uvbO1c375.jpg "style=" float: none; "title=" 3.png "alt=" Wkiol1ugpl3akwt7aab10uvbo1c375.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/13/wKiom1Ugo3qzx5HqAAB-roNUzxM443.jpg "style=" float: none; "title=" 4.png "alt=" Wkiom1ugo3qzx5hqaab-ronuzxm443.jpg "/>
-O: Displays only the content that is matched by the pattern;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5D/13/wKiom1Ugp8jxWn1oAARJrryCwCw792.jpg "title=" 10.png "Width=" "height=" 414 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:600px;height:414px; "alt=" Wkiom1ugp8jxwn1oaarjrrycwcw792.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/13/wKiom1Ugpg-gZxhTAACNCKovFVE177.jpg "style=" float: none; "title=" 8.png "alt=" Wkiom1ugpg-gzxhtaacnckovfve177.jpg "/>
-i:ignore case, character case insensitive;
-V: Displays rows that cannot be matched to the pattern;
-E: Using extended regular expressions;
-A #: Displays the number of rows specified after matching rows;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5D/13/wKiom1Ugp1SBTikeAAFkVCwzD08618.jpg "title=" 9.png " alt= "Wkiom1ugp1sbtikeaafkvcwzd08618.jpg"/>
-B #: Displays the number of rows specified before matching the line;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/13/wKiom1UgqDDS7CKQAADt41pEHgY607.jpg "title=" 12.png "alt=" Wkiom1ugqdds7ckqaadt41pehgy607.jpg "/>
-C #: Displays the number of rows specified before and after the matching line;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5D/0F/wKioL1UgqbTRO5TtAAEuf6Ua7Ug314.jpg "title=" 13.png "alt=" Wkiol1ugqbtro5ttaaeuf6ua7ug314.jpg "/>
Egrep:
Use format:
Egrep [OPTIONS] PATTERN [FILE ...]
This article is from "Just like the Beginning" blog, please be sure to keep this source http://10066605.blog.51cto.com/10056605/1629046
grep, egrep and corresponding regular expression usage