, *: matches any number of characters preceding it5,?: Match its front 0 or 1 times6, +: match its front 1 or more7, {m}: exact match m times8, {M,n}: matches at least m times, up to N times9. *: Matches any character of any length10, ^: anchor at the beginning of the line,11. $: End of line anchoring12, \13, \>: Suffix anchor (can also use \b)14. ^$: Match blank line15, (): Used with \ n (n is a number) to match the number of repetitions of a single or multiple character combinations16, |: Matc
a maximum of n times 2 . Wildcard.: Any single character []: any single character in the specified range [ ^ 3 . Anchoring character ^: anchor at the beginning of the line, usually followed by ^ must appear at the beginning of the $: End anchor, usually written in front of the string must appear at the end of the row \ > 4 . Group symbol \ (\): Group \ 1 : references the first pair of parentheses in the contents \ 2 3 2. Extended Regular
Tags: EGREP LINUX extended Regular expressionEgrep An extended regular expression implementation is similar to the grep text filtering feature: Grep-e grep [OPTIONS] PATTERN [FILE ...]
"middle for command, will be executed first, equivalent $ ()
echo "$ (date)"
{}
The middle is the command block combination or the content sequence
!
"Non" (not) in logical operation
And and, when the current one instruction executes successfully, the following command is executed
||
Or, if the current instruction fails to execute, the following command is executed
..
Top
ProfileSome of the basic tools under Linux, such as grep,awk,sed, support regular expressions. It's best to do simple regular expression practice. However, the Kingdom of the regular expressio
First, the basic wildcard characterGlobbing: File name wildcard *: Any character of any length?: any single character []: any single character in the matched range [^]: matches any single character outside the rangeSecond, the text Processing tool of Linux file processing Three MusketeersLinux Text Three musketeers: 1) grep: Text Processing tool 2) SED: Stream editor 3) awk: Text report Generator, formatted
Linux regular expression-metacharacters
We have read two basic elements in the expression:1. A value expressed as a nominal value or variable.2. An operator.Regular Expressions are composed of these identical elements. Except for metacharacters, they are interpreted as matching only the literal value of the metacharact
corresponding pattern in the right parenthesis to match the content, meaning that the previous occurrence, in \1 this also appears once\2...\ (A.B) xy\1:a6bxya6b2. Extended Regular Expressions Egrep: Use an extended regular expression to build the pattern, which is equivalent to GREP-EMetacharactersCharacter Matchi
Linux egrep file content search tool and extended regular expression detailedegrep Command : Search for text based on patterns (matching criteria for text characters and extended Regular expression meta-character combinations)and displays the line of text that conforms to th
Some friends may use regular expressions every day, such as grep, Vim, sed, and awk, but they may not be familiar with this term. Regular Expressions are generally abbreviated to RegEx, Regexp, or even re. There are many articles about regular expressions. You can find good instructions by searching for them using sear
12.1 What is a regular expressionThe regular expression is the method of processing the string, it is the behavior unit to carry on the string processing behavior, the regular expression through some special symbol auxiliary, can let the user easily to find, delete, replace
parenthesisRegular expressions are divided into two categories:1. Basic Regular Expressions2. Extending the regular expressionUsing grep-V does not match-N Display Line number-A N: Displays the found result and displays the following N rows-B N: Displays the results found and displays the first N rows-C N: Displays the found results and displays the front and ba
front 0 or 1 times6, +: match its front 1 or more7, {m}: exact match m times8, {M,n}: matches at least m times, up to N times9. *: Matches any character of any length10, ^: anchor at the beginning of the line,11. $: End of line anchoring12, \13, \>: Suffix anchor (can also use \b)14. ^$: Match blank line15, (): Used with \ n (n is a number) to match the number of repetitions of a single or multiple character combinations16, |: Match | characters before or after the symbolThree, the command that
rangeNumber of Matches* the number of previous character matches? match its preceding character 1 or 0 times+ match the characters in front of it at least once[M,n] indicates that the preceding character appears at least m times and at most n timesAnchor Point character^ Anchor The beginning of the line, any content after this character must appear at the beginning of the line$ Anchor Line end, any content in front of this character must appear at the end of the row\indicates that any subsequen
displacement function, after parsing the variable output
`
Return quotation marks, middle is command, will execute command first, $ ()
{}
The middle is the command block combination or the content sequence
!
Non -
When a command executes successfully, the following command is executed
..
Top level Directory
.
Current directory
/find/Replace value} A "/" means replacing the first, "//" means replacing all, when the lookup appears: "/" Please add escape character "//" to indicate.
Third, performance comparison
In the shell, through awk,sed,expr and so on can be implemented, the string above operation. Below we perform a performance comparison.
[Email protected] ~]$ test= ' C:/windows/boot.ini '[[Email protected] ~]$ time for I in $ (seq 10000);d o a=${#test};d one;
Real 0m0.173sUser 0m0.139sSYS 0m0.004s
[[Ema
contain a match. The output content only contains rows that do not contain the given word. For example, output all rows that do not contain the bar word:
$ grep -v bar /path/to/file
UNIX/Linux pipelines and grep commands
Grep is often used with pipelines. In this example, the name of the hard disk device is displayed:
Linux Regular Expression sed details
Sed and awk tools can replace text and output the replaced text to the screen.Sed and awk are both stream editors that operate on the lines of documents. Sed is usually used to replace an operation.
The text content of the example. follow these steps.[Root @ bkjia ~] # Cat test.txtRot: x: 0: 0: rot:/bin/bashRoot: x: 0: 0: root
Linux Regular Expression
Basic Regular Expression
^ The string to be searched by word starts with word
Grep-n "^ a" regex.txt find the row whose first character is a and output the row number
Word $ the string to be searched ends
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.