How to use the Linux egrep command

Source: Internet
Author: User
Tags egrep

The execution result of egrep is similar to that of "grep-E". The syntax and parameters used can be referred to the grep command. The difference between egrep and grep lies in the method of interpreting strings.

Egrep is interpreted using extended regular expression syntax, while grep is interpreted using basic regular expression syntax. extended regular expression is more standard than basic regular expression.

Syntax

Egrep [template mode] [file or directory]

Parameter description:

  • [Template mode]: string rule to be searched.
  • [File or directory]: find the target file or directory.

Instance

Displays the matching characters in the file. For example, to find all files in the current directory that contain the string "Linux", run the following command:

Egrep Linux *

The result is as follows:

$ Egrep Linux * # search for files containing the string "Linux" in the current directory

Testfile: hello Linux! # The following five lines contain Linux characters in testfile.

Testfile: Linux is a free Unix-type operating system.

Testfile: This is a Linux testfile!

Testfile: Linux

Testfile: Linux

Testfile1: helLinux! # The following two lines in testfile1 contain Linux characters:

Testfile1: This a Linux testfile!

# The following two rows in testfile_2 contain Linux characters:

Testfile_2: Linux is a free unix-type opterating system.

Testfile_2: Linux test

Xx00: hello Linux! # Xx00 lines containing Linux characters

Xx01: Linux is a free Unix-type operating system. # the following three actions xx01 contain Linux characters

Xx01: This is a Linux testfile!

Xx01: Linux

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.