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