The SED command can perform line matching well, but precisely match certain content from a line, you can use the grep command and the-O and-e options to achieve this purpose. -O indicates "only-matching", that is, "only matching. It is not enough to use it alone. It is very powerful to use extended regular expressions with the-e option.For example, the following text tmp.txt contains:
{"Aid": 45, "pat
Regular expressions consist of two basic character types: literal (normal) text characters and metacharacters. Metacharacters enable regular expressions to have processing power. A meta-character is a special character in a regular expression that can be used to specify its leading character (that is, the character in
once? : 0 or 1 times, the preceding characters can have, can be no{m}, {0,n}, {m,n}, {m,}: Refers to M times, up to n times, m-n times, minimum m times. *: Any length, any characterLocation anchoring:^: Anchor at the beginning of the line, mode left$: End of line anchoring, mode right\\>: Ending anchor, Word right^pattern$, matches the entire line only the specified pattern^$: Blank Line^[[:blank:]]$: No visible characters for entire line\Group() enclose any character in parentheses to make a w
expression regexpMetacharacters.: Matches any single character[]: matches a single character within a specified range[^]: matches any single character outside the specified rangeNumber of matches:*: matches the preceding character any time. *: Matches any character\? Match the preceding character 1 or 0 times+: Match the preceding character at least 1 times{M,n}: match the preceding character[Email protected] ~]# Cat/tmp/t.txtIt is open no opening###
Http://man.chinaunix.net/newsoft/grep/open.htm
1 grep Introduction
grep (Global search Regular expression (RE) and print out of the line, a comprehensive search for regular expressions and print out rows) is a powerful text sea
The feeling speaks very detailed, instantly understood the grep, regular.From:hereBrief introductiongrep (Global search Regular expression (RE) and print out of the line, full search of regular expressions and print out rows) is a powerful text search tool that uses regular
In the Linux system, there are three commonly used tools for processing text, and grep is one of the Three Musketeers, commonly known as text processing.grep is a powerful text search tool whose full name is: Globally search a Regular Expression and Print. It works by searching and filtering the text based on the given
Linux comes with the GNU grep command tool, which supports extended regular expression extended regular expressions, and GNU grep is the default for all Linux systems. The
Today, we will give a brief analysis of the grep commands and regular expressions in Linux. No matter new users or masters with rich experience, during our Linux career, the knowledge of grep commands and regular expressions is an
Match A or B or C. such as: grep|sed matching grep or sed
()
Grouping symbols, such as: Love (able|rs) ov+ match loveable or lovers, matching one or more ov.
X{m},x{m,},x{m,n}
function with x\{m\},x\{m,\},x\{m,n\}
4. POSIX character classPOSIX (The Portable Operating System Interface) adds special character classes
A. Linux Text Lookup command
Before saying Linux regular expressions, it also describes the three common commands for finding text files in Linux:
1.grep: The earliest text-matching program that uses a POSIX-defined basic regular
Read Catalogue
Simple Introduction
Some options and functions of regular expressions
Basic Regular Expressions
Extending regular Expressions
In the transport Wei Chong expression for the author must learn and master, it is a difficult point! First of all, it has a lot of meta-charact
To use rule expressions, you must add ''at both ends of the matching mode ''. In this way, it is different from the shell's file wildcard number.Regular Expression (regular exdivssion, RE)
1. What is regular notation:
What is a regular expression (
Linux Three Musketeers is a very powerful text processing tool in Linux, Master Three Musketeers, the text processing already presumably will have three swords in hand, the world I have feelings, three musketeers of the grep family is good at text search, support for regular expres
Introduction to 1.GREP commands and regular expressions(1). grep (Global search REgular expression and print out of the line), which is a powerful text-search tool in the Linux system, that searches the
to [^0-9]
5.egrep and FgrepWhen using grep, if you want to turn on an extended regular expression, you need to specify the-e option, and the EGREP command supports extended regular expressions by default. Therefore, it is recommended to use EGREP instead of GREP-
Linux grep and Regular Expressions
Grep Introduction
Grep is a powerful text search tool that uses regular expressions to search for text and print matching rows. Generally, grep has th
^$
Span style= "font-family: ' The song Body '; > indicates a blank line
\
Span style= "font-family: ' The song Body '; > Indicates the first anchor of the word, appearing on the left word of the word: a string of consecutive characters that do not contain special characters
\>
Span style= "font-family: ' The song Body '; > represents the ending anchor, appearing on the right side of the word
, and can print the matching file or text information, which can save a lot of time.In addition, regular expressions are important to system administrators! Because the system does not fill out will produce a lot of information, some of the important information is only to inform, at this time, the administrator can through the formal expression of the function to print out important information, and produc
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.