/wKioL1RyBW6gyoowAAENihiIgQE185.jpg "alt=" Wkiol1rybw6gyoowaaenihiigqe185.jpg "/>5. Find one or two digits in the/etc/passwd file;650) this.width=650; "title=" QQ picture 20141123222739.png "style=" Float:none; "src=" http://s3.51cto.com/wyfs02/M01/53/D7 /wkiom1rybplhrb48aamxu-qfgas665.jpg "alt=" Wkiom1rybplhrb48aamxu-qfgas665.jpg "/>6, displays the line that starts with at least one whitespace character in/boot/grub/grub.conf;650) this.width=650; "Width=" 857 "height=" 131 "title=" QQ picture 2
Extending regular ExpressionsExtended Regular Expression command: EgrepRegular expressions are not supported but fast: fgrepCharacter Matching:.:[]:[^]:Number of matches:*:?:+: Match the characters in front of it at least once{m}: Exact match{M,n} no backslash required:Location anchoring:^:$:\\> or \b:Group:(): Group\1,\2,\3,......Or|: or (A|B)Cases:C|cat=c or Cat(c|c) At=cat or catLazy Qualifier*? Repeat any number of times, but repeat as little as possible+? Repeat 1 or more times, but repeat
Recalling the previous chapter, in the previous chapter we described the Text Processing tool grep command, which is performed by the user according to the specified "pattern" for row matching, the default is greedy mode, the matching results are printed to standard output, and the regular expression is written by a group of special characters, Some of these characters do not represent the original literal meaning, but for the function of control or wildcard, and the regular expression of two ca
I. Introduction of EGREPEgrep is an expanded version of grep, which improves the operation of many traditional grep that cannot or is inconvenient, and uses the same usage as grep.Comparison of Egrep with grep:1. Not supported under grep? With + These two special characters, but Egrep is available.2.grep does not support a|b or (ABC|XYZ) such "or one" alignment, but Egr
Egrep
Function Description: The egrep command is the same as the grep command with the-E flag, except for the difference between the error message and the function of using the message and the-s flag. Use the egrep command to search for one or more files. The prompt can be an Extension Rule expression symbol. The Extension Rule expression symbol, including the ru
Detailed description of grep, egrep, and fgrep usage of text search commands
I. Learning Objectives
Understand and be familiar with grep, egrep, and fgrep commands.
Ii. Learning Content
1. Meaning and usage format of grep, egrep, and fgrep commands:
Grep: a command that uses the mode defined by the basic regular expression to filter text.
# Grep [Options] patter
An expression
Meaning
C
Any non-special character c that matches itself
\c
Remove any special meaning of character C
^
Header
$
End of Line
.
Any single character
[...]
... Any character in a character, a range like a-Z is legal
[^...]
Not... Any single character in the
\ n
Characters matching the nth \ (... \) (in grep only)
Tags: class number highlighting Roo postfix understanding direct. com LoginI. OverviewRegular expressions are the knowledge that is often needed in operational operations. File lookups, log parsing, rewrite rules, shell scripts, and so on, all require the knowledge of regular expressions. So what is a regular expression? My understanding is to find or replace the string you need according to certain rules, which is a regular expression, exactly, it is a rule. There are many commands to use regul
When there is only one match condition: The egrep pattern file is equivalent to the GREP-E pattern fileFor example:When multiple match conditions are available, you can only use egrep-e pattern1-e pattern2-e pattern3 ... filename,You can't use grep-e pattern1-e pattern2 filename, because grep-e pattern1-e pattern2 filename is bound to have no results. (This shows that the usage on page 125th of the Linux Sh
"Reprinted from" http://blog.csdn.net/homking/article/details/6000711
Egrep equivalent to Grep-e
Fgrep equivalent to Grep-f
GREP-E xxx-e yyy can specify multiple conditions and can contain-
Grep-a 3 print matching line and match line first 3 lines
Grep-b 3 print matching lines and 3 rows after matching lines
Grep-c 3 print matching lines and 3 rows before and after matching rows
grep--color=auto Match highlighting to a
Grep,egrep,fgrep:print lines matching a pattern1.grep:grep [options] PATTERN FILE ...Pattern is made up of meta characters and ordinary characters-I:--ignore-case, ignoring case-O:--only-matching, displays only the characters that are matched, and two is not the whole line-N:--line-number, outputs the line number of the matched row-V:--invert-match, showing all rows except matching rows-e:--extended-regexp, Egrep
Grep nobody/etc/passwd display rows with nobody characters in/etc/passwd, case sensitive
Grep-I nobody/etc/passwd real-world/etc/passwd rows with nobody characters, case insensitive
Grep-V nobody/etc/passwd rows that do not contain the nobody
Grep-N nobody/etc/passwd: displays the row containing the nobody and the row number.
Egrep is the extended grep
Egrep '2 | 5' test: List rows containing 2 or 5
Grep, egrep, and fgrep for basic regular expressions and text processing tools
Grep (Global Search Regular Expression and print out the line global search Regular Expression and print out the rows) is a powerful text search tool, the commands of egrep and fgrep are only slightly different from those of grep. Linux uses the GNU version of grep, which is very powerful and can be passed through-G,-E, -F comman
1.grep and Egrep Introduction grep full name is the global Regular Expressiongrep is a powerful text search tool for searching and filtering specific characters. Support regular expressions, can help us to filter, filter the common work. and can be used with a variety of commands through the pipeline, flexible and convenient. Its use rights are for all users. 1.1 regular Expressions (RegularExp ression REGEX )Before learning the grep
line if it contains the word North. The/
4. grep's options
Option
What it does
-B
Precedes each line by the block number on which it was found. This is sometimes useful in locating disk block numbers by context.
-C
Displays a count of Matching lines rather than displaying the lines that match.
-H
Does not display filenames.
-I
Ignores the case of letters in making comparisons (I. e., upper -- and lowercase are considered iden
Egrep and extended regular expressions, conditional expressions, and arithmetic operationsLinux05Linux05_01? Use and extend regular expressions in egrepREGEXP: REGular EXPression. It may not represent its own meaning, but it is used for special meanings such as anchoring.Pattern: filtering conditions used to filter text by combining metacharacters and characters of Regular ExpressionsRegular Expression:Basic REGEXP: BasicExtended REGEXP: ExtendedBasic
/meminfo
For example, if the default shell is not bash
# Grep-V "bash $"/etc/passwd | cut-D:-F1
For example, retrieve the user whose default shell is Bash and whose ID is the largest
# Grep "bash $"/etc/passwd | sort-n-t:-K3 | tail-1 | cut-D:-F1
For example, the/etc/rc. d/rc. sysinit file starts with #, followed by at least one blank character, and then contains at least one non-blank line.
# Grep "^ # [[: Space:] \ {1, \} [^ [: Space:] \ {1, \}"/etc/rc. d/RC. sysinit
For example, find one or tw
Regular expressions I wrote the blog for the first time. The basic use of regular expressions has just been learned recently. Organized, and later used to review the search. The basic description of regular expressions:Basically, a regular expression is a pattern used to describe a certain amount of text, and the shorthand for regular expressions is the Regex full name regular Express.The first regular expression is very important for Linux OPS engineers, which will accompany every operational e
Mode: patternRegular:grep: Basic RegularExtended grep: Extending the regularBasic Regular:. : Any single character[]: Within the specified range[^]: outside the specified rangeNumber of Matches*: Characters appear any time?: Characters appear 0 or 1 times\{m,n\}: Characters appear at least m times, at most n times\{1,\}: Characters appear at least 1 times. *: Matches any character of any lengthAnchoring:^: Anchoring the beginning of the line$: Anchor Line End\\> or \b: Anchor word endings\(\)\ (
called a word;\\> or \b: The ending anchor for the right side of the word pattern;\Second, Egrep an extended regular expression implementation is similar to the grep text filtering feature; Grep-eEgrep [OPTIONS] PATTERN [FILE ...]Options:-I,-O,-V,-Q,-A,-B,-C-G: Support for basic regular expressionsExtend the metacharacters of regular expressions:Character Matching:.: Any single character[]: Any single character within the specified range[^]: Any sing
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.