Egrep commands in CentOS

Source: Internet
Author: User
Tags grep regular expression
Egrep function description: the egrep command and the grep command have the-E flag, except for the difference in the error message and the use of the message and the function of the-s flag. Use the egrep command to search for one or more files. the prompt can be an extension rule expression symbol. the extension rule expression symbol includes the rule expression symbol. some special symbols are added on the basis of the grep command. | ---------- | Symbol | meaning | egrep

Function description:The egrep command is the same as the grep command with the-E flag, except for the difference between the error message and the use of the message and the function of the-s flag. Use the egrep command to search for one or more files. the prompt can be an extension rule expression symbol. the extension rule expression symbol, including the rule expression symbol, adds some

Special symbol.

| ---------- |

| Symbol | meaning |

| ---------- |

+: Indicates that one or more previous characters are repeated.

? : Represents the first character of zero or more

|: Indicates OR. If either of them meets the conditions.

(): Indicates the residential group, indicating that you only need to find the group in (). the content in the group can be separated by (|.

() +: Identifies duplicate groups. That is, you only need to match the content of one or more groups. And! Extended Regular expressions do not express special characters, so they can be used as common characters as an excuse.

.: Represents any character.

Instance used:

(1)

[Root @ LiWenTong test4] # egrep 'n' (e | o) + '/etc/passwd à if there is Ne in Wendan management, all start with NO will be matched.

Nobody: x: 99: 99: Nobody: // sbin/nologin

(2) search for rows that contain network admin or uucp admin

[Root @ LiWenTong test4] # egrep '(network | uucp)'/etc/passwd

Uucp: x: 10: 14: uucp:/var/spool/uucp:/sbin/nologin

(3) search for rows without digits

[Root @ linux-lwt tmp] # egrep '^ [^ 0-9] + $' 1.txt

AsdfasfEASDF

See http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856896.html


--------------------------- Subsequent personal Summary -------------------

Compared with the grep regular expression, egrep adds the Dot regular expression. For example, | or. + Repeat one or more previous characters .? Repeat 0 or more previous characters. The usage is also the same, basically for the line, can be well implemented. It depends on whether we can use it flexibly.


Related Article

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.