Linux Basics Regular Expression grep

Source: Internet
Author: User

grep full name is: Global search Regular expression and printing globally searches for regular expressions and displays them

Use regular expressions to describe the selection criteria.

Pick row selection, select a row's filter criteria, and, given the selection criteria, display only the rows that match the criteria, or only those that do not match the criteria.

There are three commands for a similar operation: grep; Egrep Fgrep

grep: The default support for basic regular expressions;

Egrep: extended regular expression;

Fgrep: The regular expression metacharacters are not supported and the search string is fast;


Regular expressions are patterns written by a class of characters (pattern)
Metacharacters: does not represent the meaning of the character itself, but is used for the description of the additional functionality;

Using a bunch of meta-characters, not representing the meaning of the metacharacters themselves, but representing the characters used to describe the function, and this description of the function or functional description of the expression written, we call it a regular expression.

Using a class of metacharacters that do not represent itself, the pattern described by combining other characters with the ability to match or conform to a pattern character is called a regular expression.

Method: grep [options] ' pattern ' file means to find a line in this file that conforms to the write pattern and display it. ' Pattern ' is used to describe the search criteria.

Example: Displaying a line that includes the root character in user attribute information
#grep ' Root '/etc/passwd
You can also highlight the results you have found;
#grep--color=auto ' root '/etc/passwd

Not to be continued


This article is from the "IT" blog, so be sure to keep this source http://yycjqr.blog.51cto.com/6587335/1410059

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.