"Regular expression of Linux"

Source: Internet
Author: User
Tags egrep

First, grep

grep family
grep, Egrep, Fgrep
Globally search a Regular Expression and Print
Find according to the pattern we provide and display the matching lines in the file
Pattern: pattern, a match condition consisting of a pure string or a meta-character

grep works in greedy mode

Grep

grep [OPTIONS] PATTERN [FILE ...] --Color: Displays the part of the matching pattern in a highlighted color -I: Ignore case to match -V: Invert selection, show no match to -o: Show only matched characters - E: Using an extended regular expression -a#: (after) displays the line that is matched by the condition and its next # line -b#:(before) displays the line that is matched by the condition and its preceding # row -c#: (context) shows the line that is matched by the condition and the # lines before and after it

Second, the regular expression of the meta-character 1, the basic regular expression
 1  . Matches of character or string occurrences  *: The characters in front of it appear 0 or any time \? : The preceding character appears 0 or 1 times \{m,n\}: The preceding character appears at least m times, with a maximum of n times  2  . Wildcard.: Any single character []: any single character in the specified range [ ^ 3  . Anchoring character  ^: anchor at the beginning of the line, usually followed by ^ must appear at the beginning of the $: End anchor, usually written in front of the string must appear at the end of the row \  < > 4  . Group symbol \ (\): Group \  1  : references the first pair of parentheses in the contents \  2   3  
2. Extended Regular Expression grep-e = Egrep
+: The preceding character appears at least once | : or () grouping can not write escape characters grep basic Regular expression, meta-character Egrep extended Regular expression, meta-character fgrep Pure string

"Regular expression of Linux"

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.