The Shell Three Musketeers grep

Source: Internet
Author: User
Tags egrep

    • Objective

How did grep get out?

It's going to take us discovering, "g/re/p" see, that's it. "Global Regular expression print" ==> "globally finds the regular expression (RE) and prints the resulting row. ”

The grep family consists of commands Grep,egrep and Fgrep. The latter two are variants of the former. One is fat, one is thin.

The advantage of using grep is that you do not need to start the editor to perform a find operation, and you do not have to put the pattern in "//", use grep much faster than VI, and many more command-line options.

    • format

Grep-option ' pattern ' filename or

|grep-option ' pattern '

    • Regex meta-character for grep

See the Shell's regular expression above:

http://1076546426.blog.51cto.com/9959876/1702784

    • grep options

Options
Function
-B Precede each line with its block number, which may be used when locating a disk block based on the context
-C Displays the number of rows matched to, without displaying the contents of the row
-H Do not display file names
-I. Ignore case when matching characters
-L Lists only the file names of the files where the matching rows are located (one at a time for each file name), separated by a newline character between the file names
-N Precede each line with its relative line number in the file
-S Silent operation, that is, only display error messages to check the exit status
-V Reverse lookup, showing only rows that do not match
-W Find the expression as a word and apply it only to grep. =====\<\>

Note: For more options, see: Grep-h or man grep

    • Egrep New Meta characters

Metacharacters
Function
+ Match one or more characters before the + sign
? Match 1 or 0 leading characters
A|b Match A or B
() Character groups

IDEA Development:

Example Annotations
' [A-z]+ove ' Match 1 or more letters followed by a ove string
' Lo?ve ' String matching L followed by Ove or ve
' Love|hate ' Match one of the two strings of love and hate
' Love (able|ly) ' Match loveable or lovely


The Shell Three Musketeers grep

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.