Linux Command Text Processing (i) grep

Source: Internet
Author: User

grep (Global Regular Expression print)

How to use:

grep [options] pattern [file1 file2 ...]


make with parameters:

[options] Main parameters:

- C : Counts the number of matching rows (count)

- N : Displays matching lines and line numbers (number)

- v : Reverse match (invert)

- I. : Ignore case (Ignore)

- L : Output only file names that contain matching characters (list of file listings)

- L : Output only file names that do not match the class characters (list of file listings)

- W : Match [pattern] as a word (word)

- v : Version number

--color : match keyword turns red


The main parameters of the pattern regular expression:

\w :  match literal and numeric character number [0-9] letter [a-z][a-z]

^ :   The beginning of the anchoring line is as follows: ' ^# ' matches all lines beginning with #.

$ : The end of the anchoring line is as follows: ' #$ ' matches all rows ending with $

. &NBSP: Matches a non-newline character such as: ' GR.P ' matches gr followed by an arbitrary character finally B

* : match 0 or more previous characters such as ' *grep ' matches all of one or more spaces followed by the grep line. * Together with any character

[] : match the range of words such as: [Gg]rep match grep and grep

\< : The positional anchor indicates what started as a line, such as \<grep, that represents the line starting with grep (ignoring the spaces preceding the grep)

\> : The positional anchor indicates what started as a line, such as grep\>, that represents the line ending with grep

\b :

x\{m\} :   Repeat characters x,m times, such as: ' A\{5\} ' matches rows containing 5 a

x\{m,\} repeat character X, at least m times, such as: ' A\{5,\} ' matches rows with at least 5 a

x\{m,n\} repeat character X, at least m times, not more than n times, such as: ' A\{5,10\} ' matches rows of 5--10 a










This article is from the "11878798" blog, please be sure to keep this source http://11888798.blog.51cto.com/11878798/1856953

Linux Command Text Processing (i) grep

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.