grep parameters
- -C: Displays the number of matching rows (that is, how many rows match);
- -N: Displays the line number of the document where the match is located;
- -I: ignore case when matching;
- -S: Error message not output;
- -V: output mismatched content;
- -O: output exactly match content;
- --color: Color display of matched content
- \: Ignore expression in Word Fu Yuan has meaning;
- ^: The start line of the matching expression;
- $: Matches the end line of an expression;
- \<: Starting from the line that matches the expression;
- \>: End of line to match expression;
- []: Specifies the range of a single character (such as [a] that a meets the requirements);
- [^]: matches any single character outside the specified range
- [-]: range, such as [A-z] that is a,b,c to Z all meet the requirements;
- . : all single characters;
- *: All characters, length can be 0;
- Catalog ll with-W for an exact match
description of the regular expression meta-character :
. : Matches any single character
*: Matches its preceding character any time
. *: Any character of any length
? : matches the preceding character 1 or 0 times
\{n,m\}: Matches characters preceding it at least n times, up to M times
Location anchoring:
^: Anchor the beginning of the line, the content after this character must appear at the beginning of the line
$: Anchor the end of the line, the content before this character must appear at the end of the row
^$: Blank Line
\< or \b: Anchor word, any character following it must appear as the first word
\> or \b: anchors the ending, any character preceding it must appear as the tail of the word
Use of Grep-a,-B,-C:
1)-A NUM #grep-a 1 aa test.txt Description: Searches from Test.txt for a line with a AA style and displays the following 1 rows of the row
2)-B NUM #grep-b 1 AA test.txt Description: Search from Test.txt for a line with a AA style and display the first 1 rows of the row
3)-C NUM #grep-C 2 AA test.txt Description: Lists file in addition to the line containing the panda style and out of its top and bottom 2 lines
Use of grep (GO)