Tags: grepGrepFilters, Egrep can be understood as grep's upgraded version1 format: grep [-cinvabc] ' word ' filename-C: Count the number of rows that meet the requirementsFor example:grep -c ‘root‘ /etc/passwdgrep -c ‘‘ /etc/passwdTotal rows of statistics files-I: Ignore case-N: Line number outputgrep -n ‘root‘ /etc/passwd-V print rows that do not meet the requirements, complement sets-an prints the line that meets the requirements and takes the follo
1, in the current system create user student Student1 Student2, find the current system named student (must appear at the beginning) of the user's account and related information, the file is/etc/passwdgrep "^student\>"/etc/passwd | Cut-d:-F32, analyze the following text in the/etc/inittab file the characteristics of the first two lines (where the number must be the same in each line), write a pattern that can be found exactly like two lines:11:1:WAIT:ETC/RC.D/RC 113:3:WAIT:ETC/RC.D/RC 3grep "^1
First, the regular expression RE regular expression1, what is the regular why use it?How can you choose the ID number in this?4403041996040127921305281971081261213605sss983040338963429231983100421321404ddddddddd5694x61242619860416291X5002xxxxxx04279521330900199806382320654126197703092303131127197105115662Numbers with X
A regular expression: a regular expression (or regular expression, called re) is a text pattern consisting of ordinary characters (such as characters A through Z) and special characters (called metacharacters). This pattern descri
A regular expression is just a notation, and as long as the tool supports this notation, the tool can handle the string of regular expressions. Vim, grep, awk, and sed all support regular expressions. It is also because they support the
the characters before the asterisk once or multiple times [] matches the characters in, it can be either a character or a character column \ to block the special meaning of a metacharacter, which can make it meaningless. Pattern \ {n \} is used to match the number of occurrences of the previous pattern. N is the number of times. The most commonly used are the beginning and end of a row, which may be used anywhere. for example, if you enter $, you can jump to the end of a row on bbs, you can als
occurrences of the previous pattern. N is the number of times. The most commonly used are the beginning and end of a row, which may be used anywhere. For example, if you enter $, you can jump to the end of a row on bbs, you can also enter $ to jump to the last article of this version. What we will talk about later is an example of their combination with specific commands. 2. grep and the regular
Tags: grep blog not alphabetic character xxxxxx extended regular regular Expression noFirst, the basic regular environment preparation[[emailprotected] oldboy]# cat /oldboy/re.txtI am oldboy teacher!I teach linux.I like badminton ball ,billiard ball and chinese chess!my blog
-character of the regular expression5. 1. \b: Match a word boundary[[emailprotected] tmp]# cat test dodoesdoxyagdoeg[[emailprotected] tmp]# grep "do\b" testdo[[emailprotected] tmp]# grep "\bdo" test dodoesdoxy[[emailprotected] tmp]# grep "\bdoes" test does[[emailprotected] tmp]#
From: http://hi.baidu.com/nearlove/blog/item/11db98b6b5b8aff831add1e5.html
The first thing to remember is that regular expressions and wildcards have different meanings!A regular expression is only a representation. As long as the tool supports this representation, the tool can process the string of a regular
, does not match A;[Email protected] ~]# grep-e "Go+d" test1My god,i am not oldbey,but OldboyGoodGoood(2)? : Match the previous 0 or 1 times---ab? Indicates matching A or AB, does not match ABB;[Email protected] ~]# grep-e "Go?d" test1My god,i am not oldbey,but OldboyGd(3) | : Match any of the---ab|cd to match ab or CD;[Email protected] ~]# grep-e "God|good" test
$ match end of line
grep "^m" Test_rule.txt
Match lines that start with capital M
grep "n$" Test_rule.txt
Matches a line ending in lowercase n
Grep-n "^$" Test_rule.txt
Match Blank Line
4 [] matches any one of the characters specified in parentheses, matching only one character
grep "S[ao]id" Test_rule.t
A regular expression is only a representation. As long as the tool supports this representation, the tool can process the string of a regular expression. Vim, grep, awk, and sed both support regular expressions, and they seem powe
The first thing to remember is that regular expressions are not the same as wildcards, and they represent different meanings!A regular expression is just a notation, and the tool can handle a string of regular expressions as long as the tool supports that notation. Vim, grep
'
Connect the display results of PS with the pipe character and grep, displaying all lines with a space at the beginning of the line and containing multi
2) EgrepEgrep is the extension of grep and can be used with other wildcard characters+: More than 1 characters? : There are 0 or 1 charactersA|b: Matches the character of A or b(): Character Group3) FgrepSimilar to
Linux regular expression 1. some special symbols 2. first-line control character ^, last-line control character $ [html] find the first rule containing the: [root @ www ~] When grep-namp;%39%%theamp;%39%regular_express.txt start with a lowercase letter: # grep-n amp; #39; ^
: print only the letter grep "\w" H.txt --A B c d e F g h i \w : print non-letter \b : match the delimiter of the word grep "\bhello\b" h.txt\d : Represents a numberCommon Command DisplayLinux grep/egrep Command DetailedLinux sed command detailedLinux awk Command DetailsExtended Regular ExpressionExtended
1. What is a regular expressionWhen doing a word processing or writing a program, use the
Find, replaceand other functions,
use regular expressions to achieve goals quickly and easily。 In simple terms, regular expressions help with some special symbols, so that users can easily and quickly complete the search, deletion, replacement and other processing programs.
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.