Egrep: Use an extended regular expression to build the pattern, which is equivalent to GREP-E
Meta characters :
Character Matching :
. : Any single character
[]: Specify any single character in the range
[^]: Any single character outside the specified range
number of matches :
*: Matches its preceding character any time
?: Match its preceding character 0 or 1 times
+: Match its preceding character 1 or more times
{m}: Matches M-Times
{m,n}: At least m times, up to N times
{m,}: at least m times
{0,n}: Up to N times
anchoring :
^: Beginning of the line
$: End of line
\<,\b: the first word
\>,\b: Ending
Group :
(): Group
|: or example: AC|BC, which represents AC or BC, if a (c|b) C, indicates ACC,ABC
Fgrep:fast, do not parse regular expression, need to find what directly in the mode to fill in the corresponding content can be
Practice :
1. Find the line that ends with "LISTEN" or "established" in the results of the Netstat-tan command execution
#netstat-tan | grep--color=auto-e "listen| Established[[:space:]]* "
2. Matching IP address
#ifconfig | Grep-e--color=auto "(\< ([1-9]|[ 1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]) \>\.) {3} (\< ([0-9]|[ 1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]) \>) "
16. Self-Learning Linux path: Text Processing tool Egrep,fgrep