Original link http://blog.csdn.net/yaochunnian/article/details/7261006grep file Error "binary file ... matches" cause: file for binary files resolved: Strings Vers.log. .-Geneva- the| grep-i ' Mezimedia ' or grep-a-i ' Mezimedia ' Vers.log. .-Geneva- theThe grep command is a line filter tool under Linux, its parameters are numerous, the following is a description
expression-e option:Grep-e "[1-9]+" or egrep "[1-9]+"Output only the portion of the file that matches to the-o option:Echo this was a test line. | Grep-o-E "[A-z]+\."]Line.Echo this was a test line. | Egrep-o "[A-z]+\.]Line.The number of rows in the statistics file or text containing the matching string-C option:Grep-c "Text" file_nameThe output contains the num
fit me.............However, it is much easier to use egrep and extended special symbols that support extended regular expressions. Note that grep supports only underlying expressions, while Egrep supports extensions, in fact Egrep is an alias for GREP-E. Therefore, the
.。 : all the individual characters.*: There are characters, the length can be 0.
The grep command uses a simple instance
$ grep ' test ' d*Displays the rows that contain test in all files that start with D.$ grep ' test ' AA bb ccDisplays the row that matches test in the aa,bb,cc file.$ grep ' [a-z]\{5\} ' AADisplays
[Email protected] ~]# grep-r "192.168.57.9"/etc/Output results/etc/sysconfig/network-scripts/ifcfg-eth0:ipaddr=192.168.57.9You will see that the results of the search to 192.168.57.9 each row are prefixed to find a matching file name. The file name contained in the output can be added with the-H option to suppress the output:Such as:[Email protected] ~]# grep-hr "192.168.57.9"/etc/ipaddr=192.168.57.9Or[Emai
message. -V Reverse lookup. -W displays only the columns that match the whole word. -X displays only the columns that are eligible for all columns. -y This parameter effect is the same as "-I". -O outputs only the portion of the file that matches. Iii. common usage of GREP commandsSearching for a word in the file, the command returns a line of text containing "Match_pattern":"Match_pattern" file_nameFind in multiple files:grep "Match_pattern" File_1
consecutive lowercase characters for each string. $ grep‘W\ (es\) t.*\1′aa If West is matched, es is stored in memory, labeled 1, and then searched for any character (.*), these characters are followed by another ES (\1), locate the row that is displayed. If you use Egrep or GREP-E, you do not need the "\" number to escape, directly written as 'W(es) t.*\1you can have it. 5The .
meanings, if there is an extended regular expression, with + can express 1 to 1 or more.\{n,m\} \{n,\} \{\,m}Extending regular ExpressionsBe sure to note that extended regular expressions are written as Egrep+ Previous * Corresponds to one or more of the previous charactersEgrep ' ^[^a-z]+$ ' = grep ' ^[^a-z][^a-z]*$ '? 0 or one of the previous characters| Or() a set of characters() + Multiple repeating gr
Application background: We just added a user Luffy, but we don't know what its default shell is.
Q: How do I retrieve a user's default shell?
Solution:
# Grep '^ Luffy \>'/etc/passwd | cut-D:-F7
/Bin/bashf
Through the above method, we get the default shell of the user Luffy.
Text Search Tool: it is used to match lines by line based on the text mode specified by the user, and finally obtain lines that conform to the text mode.
vertical delimiter is used to select a or E instead of GRA and EY), "(grand)? Father" matches father and grandfather (the scope is experienced here?). Matches the contents of the parentheses as a whole).Iv. Grammar (part)There are many different styles of regular expressions, and here are some common regular expression matching rules for Perl and Python programming languages and grep or egrep that are comm
: End of line to match regular expression.[]: A single character, such as [a], a meets the requirements.[-]: range, such as [A-z], i.e. A, B, C to Z all meet the requirements.。 : all the individual characters.*: There are characters, the length can be 0.4.grep command uses a simple instance$ grep ' test ' d*Displays all rows that contain test in a file that begins with D.$
Tags: DMI pre pass CAT GRE share image opened color nbspDescriptionThe grep command in a Linux system is a powerful text search tool that uses regular expressions to search for text and print matching lines. we often use it to filter out the data we want in our work. Format:grep [OPTIONS]Basic parameters: -I is case insensitive-V excludes content, which is reversed-N Prints the corresponding line number to the matched content-e Using extended re
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-
= "font-family: ' Times New Roman ';" >shell /sbin/ Nologin /etc a row in the /passwd file that has the same user name as its shell name#useradd bash#useradd testbash#useradd basher#useradd nologin-s/sbin/nologin#grep "^\ (\8, find A word in the/etc/rc.d/init.d/functions file (the middle of the word can be underlined) followed by a set of parentheses linegrep "\9, use echo to output a path, and then egrep
The grep command is a row filtering tool in Linux with a wide range of parameters. The following describes the functions of each parameter and hopes to help you.Grep -- print lines matching a pattern (list the rows that match the style)◎ Syntax: grep [Options]Pattern [file...]Grep is used to compare the corresponding part in the file, or when no file is specified
The grep command is a row filtering tool in linux with a wide range of parameters. The following describes the functions of each parameter and hopes to help you.Grep -- print lines matching a pattern (list the rows that match the style)◎ Syntax: grep [options]PATTERN [FILE...]Grep is used to compare the corresponding part in the file, or when no file is specified
expression.$: Matches the end line of the regular expression.\\>: End of line to match regular expression.[]: A single character, such as [a], a meets the requirements.[-]: range, such as [A-z], i.e. A, B, C to Z all meet the requirements.。 : all the individual characters.*: There are characters, the length can be 0.4.grep command uses a simple instance$ grep ' test ' d*Displays all rows that contain test
"*.log"-type f-print| Xargs grep-i DB0Find. -type f |xargs grep-i "Mary"Retrieving a string in all files MaryLS *~ |xargs RM-RFDelete all files ending with ~SVN Filter svn folder1. Double-layer "filter" using a pipe, where the second grep uses the- voption, which isInverse MatchingTo print out rows that do not matchGrep-r 'function_name' * |
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.