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 looks for a string in the data, the data is filtered in the "Whole row" unit.Example: grep--color=auto "Root"/etc/passwdThe Egrep
;
# Cut-D:-F7/etc/passwd | sort-u
2. Extended Regular Expression
Egrep: uses an extended regular expression to construct the mode, which is equivalent to grep-e.
Character match:
.: Any single character
[]: Any single character in the specified range
[^]: Any single character out of the specified range
Matching times:
*: Match any character before it;
? : Match the first character 0 or 1 time;
+: Match the first character at least once
{M}: match th
the extension.[FILE ...] Text content Description:/home/love.txt How to find the path to textecho ' abc ' | grep--color=auto ' ABC ' transmits text content in a "pipe" way. Pipeline do not understand please niang pipe article.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Egrep with grep, you do not need to add the "-e" option when using the extended regular.Big rookie wish: a higher level. Welcome to the B
used for research useClass A: First paragraph of IP from 1-127Class B: First paragraph of IP from 127-191Class C: The first segment of IP from 192-223There are three grep commands, except grep, Egrep, and a fgrep commandgrep only supports commands for basic regular expressions by defaultEgrep is a command that supports extended regular expressionsFgrep = Fast grep quick grepgrep does a pattern match to search for text, which wastes a lot of CPU clock
Grep-I ignores case--color Plus Color-V shows rows that are not matched to-O displays only the string that is matched toGrep-o ROOT/ETC/PASSWD | Wc-l find how many root strings there are-e Use extended regular expression egrep=grep-e-A # grep-a 2 ' ^core ID '/proc/cpuinfo-B # grep-b 2 ' ^core ID '/proc/cpuinfo-C # grep-c 2 ' ^core ID '/proc/cpuinfoRegular Expressions: Basic REGEXTP BasicsExtended regextp ExtensionRegular expressions. Represents any si
times up to N times, less than the base regular expression curly bracesAnchor character:\Group:(): No need to add \ support \1,\2,\3,...Or:|:or orEg:a|b A or BEg:c|cat==c or cat (not cat or cat)grep: Searches for text according to the pattern and displays lines of text that conform to the pattern. a command that uses a basic regular expression and its defined pattern to filter text. Pattern: The matching criteria for the combination of meta-characters of the expression wildcards regular the pat
) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/85/86/wKioL1enOoawqYciAADHo1B8ojs316.gif "title=" Grep-f6.gif "alt=" Wkiol1enooawqyciaadho1b8ojs316.gif "/>The extension regular expression is used here because it can be more concise than an expression.It is important to note that a two-bit or three-digit string is required to anchor the character at the beginning and end of the7. Find the line at the beginning of the/etc/rc.d/init.d/functions file that has a word (including an underscore)
, ...Features that increase compared to basic regular expressions| : ORA|b: Indicates a or bC|cat: Indicates C or cat(C|C) at: Indicates Cat or catUsing the example650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7D/04/wKiom1bedyriKT60AAArB_vE_Ds116.png "title=" Grep23.png "alt=" Wkiom1bedyrikt60aaarb_ve_ds116.png "/>Egrep: Support for grep commands using extended regular expressions, equivalent to GREP-E;Fgrep: Support for grep commands usi
Egrep
Feature Description: The Egrep command is the same as the grep command with the-e flag, except that the error message and the use message are different and the S-flag function is different. To search for one or more files using the Egrep command, the prompt can be an extension of the rule expression symbol. Extended rule expression symbols including rule e
1.1, the basic definition: www.2cto.comgrep (Global search regular RE) and print out of the line, full search of regular expressions and print out the lines, is a powerful text search tool that can only use basic regular expressions to search for text and print 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 looks for a string in the data, the data is
^: Beginning of line, any content after this character must appear at the beginning of the line$: End of line.^$: Blank Line\\> or \b: Any preceding character must appear as the tail of the word4) Grouping\(\)\ (ab\) *: AB appears 0 times or any time\Line ending with a number[0-9]$ or grep ' [[:d igit:]]$ '/etc/inittabMatch lines that end with one or more spaces and numbers[[: Space:]] [0-9]$grep ' ^r. T '/etc/passwdgrep ' y$ ' line ending with Ygrep ' R.. T '/etc/passwd: Starts with R, ends wit
, 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" test1My god,i am not oldbey,but OldboyGood(4) (): Match Expression---A (CD) e indicates matching Ace or ADE, does not match AE;[[email prot
Text Processing Three musketeers:grep system: grep, Egrep, Fgrep, Text Search tool, based on "PATTERN" for a given text fuzzy search, grep system is working in greedy mode by default.Sed:stream Editor, Stream editor, line editor, text Editing tool;Awk:gawk--gun awk, text Formatting tool, text Report generator, text processing programming language;grep system:grep: Use regular expressions to search globally and display matching rows;grep [OPTIONS] PATT
The corresponding regular expressions and usages of grep and egrep in the grep family.The 1.grep family is one of the three great musketeers of text processing. (Grep,sed,awk)grep: (Global search REgular expression and Print out of the line). It supports the use of basic regular expressions.Egrep: supports the use of extended regular expressionsFgrep: using regular expressions is not supported (typically used in large Web site log searches)The role of
.x86_64 ro root=uuid=57d85756-7680-4c7c-9125-6ad67dae2c45 Rd_NO_LUKS rd_NO_LVM LANG=en _us. UTF-8 rd_no_md sysfont=latarcyrheb-sun16 crashkernel=auto keyboardtype=pc keytable=us Rd_NO_DM quietInitrd/initramfs-2.6.32-504.el6.x86_64.img[Email protected] ~]#GREP-E = Egrep4. Display all files that end with a number and do not contain a blank in the file name;LS *[^[:space:]]*[0-9]?????????Find the number between 1-255 in the/boot/grub/grub.conf file;\\.Ifconfig |
We often need to search the documentation for content that meets our requirements, which may be scattered around the document in every corner. Can use keywords such as/keyword or? Keyword one search, and I might not just want to search for keywords, but to specify a range, how to do? And how do you show the contents of these searches in a centralized way? The grep command and the Egrep command, which uses regular expressions to search for strings, can
Personal Insights: I think the text processing commands in Linux the grep egrep fgrep command is just as easy as mastering grep because the other two are almost the same, and the difference is very good.grep Basic Use method:Using the method grep [option] ' expression ' #学习的时候没好好听 don't know that I wrote it wrong, not for this post. Usually I don't read the video I studied before.The common options here are-o-v-i-n-a-b-C-Digital-E[emailprotected]:~#gr
The Three Musketeers of text processing under LinuxThe first sword grep, Egrep, Fgrep: Text Search tool; Search operations on given text based on "pattern";The second Sword Sed:stream editor, stream editor, line editing tools, text editing tools;Third Sword Awk:gnu awk, text formatting tool; Text Report Generator;Today, we mainly explain the first sword:grep family:grep: Supports the use of basic regular expressions;
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 regular RE) and print out of the line, a comprehensive search for regular expressions and print out rows) is a powe
Egrep: Use an extended regular expression to build the pattern, which is equivalent to GREP-E Meta characters : Character Matching :. : Any single character []: Specify any single character in the range [^]: Any single character outside the specified range number of matches : *: Matches its preceding character any time ?: Match its preceding character 0 or 1 times+: Match its preceding character 1 or more tim
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.