CentOS egrep Command Detailed

Source: Internet
Author: User
Tags regular expression centos egrep

Egrep

Feature Description: The Egrep command is the same as the grep command with the-e flag, except that the error message and the use message are different and the S-flag function is different. To search for one or more files using the Egrep command, the prompt can be an extension of the rule expression symbol. Extended rule expression symbols including rule expression symbols add some to the grep command based on the

Special symbols.

| —————————— |

Symbol | meaning |

| —————————— |

+: Indicates repetition of one or more previous characters

? : Represents 0 or 0 previous characters

| To express or mean. As long as one of the two is satisfied, it indicates that the condition is met.

(): Represents a dwelling group, which means that as long as the group is identified (), the content within the group can be used or (|) Separated.

() +: Represents the judgment of a repeating group. That is, just meet the content of one or more groups. And! In an extended regular expression it is not a special character, so it can be used as an excuse for ordinary characters.

. : Represents any character.

Use instance:

(1)

[Root@liwentong test4]# egrep ' N (e|o) + '/etc/passwdà if the admin has a ne,no the beginning will be matched.

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

(2) Search for lines that include 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 lines without numbers

[ROOT@LINUX-LWT tmp]# egrep ' ^[^0-9]+$ ' 1.txt

Asdfasfeasdf

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.