Linux grep command

Source: Internet
Author: User

Summary of the Three Musketeers ' grep command

1. grep

(1) The grep command plus the-v parameter indicates that the content containing Linux is not output

[email protected] data]# CAT ABC

I am Oldboy

Oldboy

Oldgirl

I am studying Linux

I am Eric

[[email protected] data]# GREP-V linux ABC

I am Oldboy

Oldboy

Oldgirl

I am Eric

(2) grep is directly added to Linux, indicating that the output contains the Linux content of the line, grep is output by " line "

[email protected] data]# CAT ABC

I am Oldboy

Oldboy

Oldgirl

I am studying Linux

I am Eric

[[email protected] data]# grep linux ABC

I am studying Linux

(3) grep home plus the usage of the expression ^ denotes what begins with, this example indicates that the output begins with old

[[email protected] data]# grep ^oldboy ABC

Oldboy

[[email protected] data]# grep ^old ABC

Oldboy

Oldgirl

[email protected] data]# CAT ABC

I am Oldboy

Oldboy

Oldgirl

I am studying Linux

I am Eric

(4) grep searches for a character ending with an x character

[[email protected] data]# grep x$ ABC

I am studying Linux

(5) Grep–n with row count output

[email protected] data]# CAT ABC

I am Oldboy

Oldboy

Oldgirl

I am studying Linux

I am Eric

[Email protected] data]# grep-n oldboy ABC

1:i am Oldboy

2:oldboy

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.