Use of grep (GO)

Source: Internet
Author: User

grep parameters

    1. -C: Displays the number of matching rows (that is, how many rows match);
    2. -N: Displays the line number of the document where the match is located;
    3. -I: ignore case when matching;
    4. -S: Error message not output;
    5. -V: output mismatched content;
    6. -O: output exactly match content;
    7. --color: Color display of matched content
    8. \: Ignore expression in Word Fu Yuan has meaning;
    9. ^: The start line of the matching expression;
    10. $: Matches the end line of an expression;
    11. \<: Starting from the line that matches the expression;
    12. \>: End of line to match expression;
    13. []: Specifies the range of a single character (such as [a] that a meets the requirements);
    14. [^]: matches any single character outside the specified range
    15. [-]: range, such as [A-z] that is a,b,c to Z all meet the requirements;
    16. . : all single characters;
    17. *: All characters, length can be 0;
    18. 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.