Regular expression format
Regular expression metacharacters:
. Match any single character
*: match the preceding characters any number of times
? Match the preceding characters once or 0 times
\ {mdirection n\}: match the preceding characters at least m times and n times at most
Position Anchor:
^: anchor the beginning of the line, and the content after this character must appear at the beginning of the line
$: anchor the end of the line, and the content after this character must appear at the end of the line
^ $: blank line
\
< :其后面的内容必须作为单词首部出现 \>The content after it must appear as the end of the word
[]: any character in the specified range. Egrep [q,w] / tmp/test
Regular expression of extension:
. Match any single character
*: match the preceding characters any number of times
? Match the preceding characters once or 0 times
+: match the preceding characters at least once
{m,n}:
C | Cat! = c | (Cat)
Example: ifconfig | egrep-o "(\\.) {3}\" you can get all the IP
Integer judgment
-eq equals
-ne is not equal to
-gt is greater than
-ge greater than or equal to
-lt less than
-le is less than or equal to
Document judgment
-e: whether the file exists
-f: test whether the file is a normal file
-d: test whether it is a directory
-r
-w read and write execution is for the current user
-x
String test
=, =: [string1 = string2] or [string1 = = string2]
! =: test whether two strings are not equal to
-n string: tests whether the specified string is empty
-z string: tests whether the specified string is not empty