What is a regularA regular is a way to describe a character or string by combining symbols with special meanings, called regular Expressions . Or, the regular is the rule used to describe a class of things.in Linux, wildcards are interpreted by the shell, while regular expre
with the decimal point:
[[emailprotected] ~]# grep -n ‘\.$‘ regular_express.txt1:"Open Source" is a good mechanism to develop programs.2:apple is my favorite food.3:Football game is not use feet only.4:this dress doesn‘t fit me.10:motorcycle is cheap than car.11:This window is clear.12:the symbol ‘*‘ is represented as start.15:You are the best is mean you are the no. 1.16:The world
Note that because the decimal point has other meanings (which will b
The regular expression used for grep in bash, bashgrep
Regular Expressions are expressions used to match texts. They are often used to express search conditions in grep commands. In fact, it is equivalent to setting some advanced requirements when you use Baidu search. For e
special character before the special character is removed
* Indicates repetition of 0 to infinity before a re (regular expression) character
[List] Indicates a search for a string containing a list
[N1-N2] Indicates a search for the specified string range, such as [0-9] [A-z] [a-z], and so on
[^list] represents the range of the reverse string, for example [0-9] for non-numeric characters, [A-z] for non-upp
, that is, the end of a row.
Example: Love $ matches all rows ending with love
^ $: The beginning and end of a row, indicating a blank row
\
Example: \
\>: The end of the word. You can use \ B to match the right of the word.
Example: love \> match the line containing the word ending with love
D. GROUP:
\ (\): The content matched by the mode in the group, which can be remembered by the regular expression i
1. grep basic syntax
The role of grep is to search. Unlike find, grep is as follows:
Find is used to search for directories and file names.
Grep is basically used to retrieve file content, strings, etc.
grep [OPTIONS] PATTERN [FILE...]
Regular expression: Regual expression,regexpA pattern written by a class of special characters and text characters, where some characters do not represent their literal meanings, but are used to denote control or the function of a wildcard.Divided into two categories:Basic Regular Expressions: BREExtended
First, grep briefgrep is a command that matches and displays the contents of Plain text in Linux according to a certain search condition . Some of the vernacular, that is, according to the user-given filter mode, the text of the content to match and display. The usage format of grep:grep [OPTIONS] PATTERN [FILE]650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7D/41/wKiom1bjrqiTMvqRAAATYWKbdt8152.
Regular Expression learning Summary
What is a regular expression?
Regular Expression, Also knownRegular Representation,General notation(English: Regular
grep and regular Expressions
GrepSearches for text based on the pattern (the combination of metacharacters of the text Word wildcards regular the expression) and displays the line of text that conforms to the pattern.
1.1grep Family:grep : Commands used by basic regul
grep (Global search regular RE) is a powerful text search tool that only uses basic regular expressions to search for text and prints matching lines.grep is a common and commonly used command, and its main function is to compare string data and then print out strings that match the user's needs, but the idea is that when grep
Summary of the use of grep and examples of how to display
Basic usage: grep is used as a text search tool to search the target text row by line based on user-specified filters (written by metacharacters and text characters of the regular expression) and display the matching rows
Format:
characters? Represents 0 or 1 characters in front of each otherwhere, +? GREP is not supported, EGREP is supported.^ The character following the beginning of the anchor line, which must appear at the beginning of the line$ anchor Line end, character following this character, must appear at the end of the row"^" in [^] denotes non-meaning^$ Empty LineAny character after \Any character in front of the \> or \b must appear as the tail of the word\\ (\)
;. *: matches any character of any length;Location anchoring:^: anchor at the beginning of the line, for the leftmost mode;$: end of line anchoring; for the rightmost side of the pattern;\first anchor of the word; the left side of the pattern used to denote the word ;\> \b: the ending anchor; the right side of the pattern used to represent the word ;^$: blank line;Group:\ (\)The contents of the pattern in the grouped parentheses are recorded by the regular
GREP is the abbreviation for global search Regular Expression and Print out of the line.1. Basic usage of GREP commandsCommand format: grep [options] [mode] [file ...]
Options
Significance
-C
Output only the number of matching rows
Regular Expressions (REGGXP):A regular expression is a filtering logic (that is, a pattern) of a string. is a pattern written by metacharacters and normal characters, in which the metacharacters do not represent the meaning of the character itself, but are used to express control or to function as a wildcard, and can be divided into two types:1. Basic
1.1) grep: is a text Search tool. The so-called metacharacters is not meant literal meaning, meta-character expression control or wildcard functions2) Fgep:fast, does not support regular expressions, when literal representation."Grep"1. Basic regular
Grep: the filtering tool comprehensively searches for regular expressions and displays grep, egrep, fgrepgrep [options] PATTERN (PATTERN) or file... regular Expression. metacharacters are one or more characters that replace one or more characters. For example :*? [] Re-I is
Grep-e =egrep+ one or more characters preceding the plus sign[Email protected] ~]# egrep--color ' R+o ' 1.txtroot:x:0:0:root:/root:/bin/bashdrooaemon:x:2:2:daemon:/sbin:/sbin/ Nologinoperator:x:11:0:operator:/root:/sbin/nologin. Represents any one character* Represents 0 or more * preceding characters. * Any of any characters? 0 or 1? The preceding character+ 1 or more + preceding charactersThis article is from "L
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.