Linux--grep command

Source: Internet
Author: User

a , function :

the grep command in a Linux system is a powerful text search tool that uses regular expressions to search for text and print matching lines .

Second, usage:

grep [Options] ... PATTERN [FILE] ...

Find the PATTERN in each file or standard input. The default PATTERN is a basic regular expression (abbreviated to BRE).

For example:

Grep-i ' Hello World ' menu.h main.c

Three, the main parameters:

-G, PATTERN is a basic regular expression (abbreviated to BRE)

-P, PATTERN is a Perl regular expression

-E, using PATTERN to perform matching operations

-F, get PATTERN from FILE

-I, ignoring case

-W, forcing PATTERN to match only words exactly

-X, forcing PATTERN to match only one line exactly

-Z, a 0-byte data row, but not empty

' Egrep ' is ' grep-e '. ' Fgrep ' is ' grep-f '. Direct use of ' egrep ' or ' fgrep ' is not available. The standard input is read without the file parameter, or file as-. The-h parameter is used by default if fewer than two file parameters are available. If any row is selected, the exit status is 0, otherwise 1, if there is an error, and the-Q parameter is not specified, the exit status is 2.





Linux--grep command

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.