grep command:
grep full Name: Global Regular expression Print, which fully searches the regular expression and prints out the line, with the function of the egrep using the parameter-E
The difference between grep and Egrep is that grep supports only the underlying regular expression, while the Egrep can support extended regular expressions
Common usage:
' Search String ' filename Options and Parameters:-A: How many times the binary file searches for the data ' search string ' as a text file-i : Ignores case differences, so case is considered the same -N: The line thatoutputs the row number ' search string ' content! --color=auto: Can be found in the keyword part of the color display Oh!
Advanced Parameters:
-A: followed by the number, in addition to listing the row, the subsequent n rows are also listed -B: After the addition of numbers, for befer meaning, in addition to listing the row, the preceding n rows are also listed --color= " This " is isn't use feet only this dress doesn ' t Fit me. Go!go!let's GO!!! 42500000491
Regular Expressions:
In simple terms, the regular expression is the method of processing the string, the behavior unit for the string processing behavior, the regular expression through some special symbols of the auxiliary, so that users can easily find, delete, replace a particular string of handlers
^word |
search beginning with Word The line |
word$ |
search for a line ending with Word |
. |
Represents and can only represent any one character |
\ |
escape symbols |
* |
means repeating 0 or more preceding characters (all other places in Linux, Example *.php, representing all files with the suffix php) |
. * |
Match all characters |
^.* |
Content that starts with any character |
[Word] |
matches any one of the characters in Word |
[^word] |
Matches all content that does not contain any characters after ^ |
\{n,m\} |
matches the previous character repeats N to M of the previous line "\ is an escape symbol, if egrep can be removed slash" |
\{n,\} |
matches the previous line with the last character repeat number at least n times |
\{n\} |
matches the line with the previous character repeated n times |
example 1:[[email protected] tmp]# grep"^th"Regular_express.txt ThisDress doesn't fit me.example 2:[[email protected] tmp]# grep"y$"Regular_express.txt"Open Source" isa good mechanism to devolop programsyapple isMy favorite Foody example 3:[[email protected] tmp]# grep"425.0"Regular_express.txt42500000491 425000491example 4:[[email protected] tmp]# grep"\."Regular_express.txt ThisDress doesn't fit me. "If just". ", will match all"example 5:[[email protected] tmp]# grep"4250*49"Regular_express.txt42500000491425491425000491example 6:[[email protected] tmp]# grep [AEO] Regular_express.txt"Open Source" isa good mechanism to devolop programsyapple ismy favorite Foodyfootball agame isNot use feet only ThisDress doesn't fit me.Go!go!let's GO!!!example 7:[[email protected] tmp]# grep'0\{3,\}'Regular_express.txt42500000491425491
Extended Regular Expression
+ |
Represents repeating one or more of the preceding characters |
? |
0 or 1 characters |
| |
Find multiple matching strings in a way or |
() |
Find a "group" string (for example, find glad or Glod two strings, grep ' G (la|lo) d ' regular_express |
()+ |
Discrimination of multiple repeating groups in D |
The---Grep,sed,awk and regular expressions of the Three Musketeers of Linux