The grep lookup string for the Advanced Linux command

Source: Internet
Author: User

Purpose: Use the grep command to find a string that matches a condition in a file

Format: grep "Options" "Find Mode" "File name"

When looking for a string, you want to display the following:

1) file name-------------------------grep displays the target file name by default when looking

2) where the line number----------------------------use the-n option

Grep-rn "string" file name

R (Recursive) recursion

N (number) displays the line numbers of the target locations

String: The string to find

FileName: The target file to locate, or * to find all files and directories in the current directory

Grep-n "abc" Test1.txt find string ABC in Test1.txt

GREP-RN "ABC" * in When directory recursively finds string ABC

Attention:

Can join-W to match whole word

GREP-RNW "abc" Test1.txt "


This article from "Van Gogh said my brain is sick" blog, declined reprint!

The grep lookup string for the Advanced Linux 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.