Need for text lookupGrep,egrep, Fgrepgrep: Search for text based on pattern and display the text lines of the review modePattern: Text Word wildcards regular the expression's meta-character combination to match the conditiongrep [Options] PATTERN [FILE ...]-i:ignore Case ignores capitalization--color: Matched to the word Fugauliang display-V: Show rows that are not matched by the pattern-O: Displays only strings that are matched by the pattern*: Any c
together and treated as a whole; xy *abNote: The contents of the pattern in the grouping brackets are recorded in internal variables by the regular expression engine, which are named: \1, \2, \3, ...\1: From the left, the first opening parenthesis and the matching closing parenthesis to match the pattern between the characters; ab\+\ (xy *\):\1:ab\+ xy *\2:xyBack reference: References the
The need for text lookup:
Grep,egrep,fgrep
grep: Searches the text according to the pattern, and displays the line of conformance to the pattern,
Pattern: A matching condition in which a literal character wildcards expressions a combination of the metacharacters of an expression
Format: grep [option] Pattern file ...
-
Regular Expressions (Regular expression (RE))is through the arrangement of some special characters to "search/replace/delete" one or more columns of text string, in short, the regular expression is used in the processing of a string "exp
8. using regular Expressions with grep Regular expression: He uses a string to describe, match some of the syntax rules of a string, so that these rules of the syntax of the string, the corresponding processing.Common support for regular
There are two types of regular expressions:Basic REGEXP: BasicsExtended REGEXP: ExtendedBasic Regular Expressions:. : Any single character[]: A single character in the specified range[^]: Specify a single character outside the rangeNumber of matches:*: The characters in front of it any time\?:0 or 1 times\{m,n\}: At least m times, up to N times. *: Any character of any lengthAnchoring:^: Anchor at the begin
regular expression-I: Ignore case search-O: Show only what you have searched for-V: do not display the searched content-N: Show line numbers-E: Pattern search defined with extended regular expression-A #: Displays the matched lines and the following # lines-B #: Displays the matched line and its previous # line conten
I. Regular Expressions
The use of a system is not only the installation, debugging, and maintenance of software, but also the optimization and reform of the existing environment, in linux, we always encounter many descriptions of parameters. Sometimes we need the answer given by the parameter itself. Sometimes we only need the final State result of the parameter.
Is a set of special or not very special stri
grep print lines matching a pattern printing line matching modegrep This command is used to query and match a string in a text fileExample grep ' root '/etc/passwd This command is used to match the line that contains the root string in the passwd file[[email protected] ~]# grep ' root '/etc/passwdRoot:x:0:0:root:/root:/bin/bashOperator:x:11:0:operator:/root:/sbin
1. grep is a powerful text search tool that uses regular expressions to match.
Format is: Gerp option ' script ' file
2, Regular expression:
(1) of which characters: +,. , (), |,{}.
In datum mode: The meaning of ordinary characters, the need for escape \.
In extended mode: Take special meaning.
(2) Character class:
. :
For shell, sed, grep, and regular expressions in LINUX, you must learn about the common Linux technology-Linux programming and kernel information. For more information, see the following. For example, for a person working in LINUX
First, grep, egrep, Fgrep command
In this paper, we mainly introduce the basic parameters and usage formats and methods of the Egrep fgrep commands and regular expressions under the Linux system. (Note: The FG represents an example in the text)
1.1, the basic definition:
grep (Global search
First, regular expressionBefore learning the Find command, we have been exposed to some simple regular, so we can now learn some complex regularization. First of all, we still have to review what is regular expression, see this tutorial first, must see a few times, at least know the
\(\): Groupinggrep "\ (ab\) *" File Indicates that there is a line of AB in the file and no ab line appears.3 , grep: A command to filter text using a pattern defined by a basic regular expression (default)-i-v-o--color are basic regular Expressions- e : Using an extended regu
this character must appear at the end of the rowExample: Show the line in the/etc/passwd file that the bash endsgrep ' bash$ '/etc/passwd^$: Indicates a blank line\\> or \b: anchors the ending, any character preceding it must appear as the tail of the wordExample: Displays a line in the/etc/passwd file that begins with Root and ends with the root wordgrep ' ^root\> '/etc/passwd650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7E/E4/wKioL1cMZ6aARz1JAACg2ippFjs572.jpg "title=" Grep2.jpg
Linux regular expression-positioning metacharacters and linux Regular Expressions
Two metacharacters are used to specify whether a string appears at the beginning or end of a row. A single character regular
.
You can see that 11 of each row has a tab (BACKSPACE) character, so you can find it precisely by using the Regular Expression tab (BACKSPACE) 11tab.
However, if you use the command cat delete.log |grep ' \t11\t ' |WC or cat delete.log |grep ' \\t11\\t ' |WC do not find one.
In fact, there are two ways to correctly
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.