15. Self-Learning Linux path: Text Processing tools Grep,eprep and Fgrep

Source: Internet
Author: User

Text Processing Tools Grep,eprep and Fgrep:

grep: (Global search regular expression and print out of the line), full search of regular expressions and display of corresponding rows

Text Search Tool: line-by-line search of target files based on user-specified text patterns, showing rows that can be matched by patterns

Format: grep [options] ' PATTERN ' file,..... Text Filter

--color=auto: Add color to the pattern you match to

Example: #grep--color=auto boot/etc/rc.d/rc.sysinit

    

Build pattern: Called a regular expression, is a pattern written by a type of character (pattern)

Metacharacters: does not represent the meaning of the character itself, for the description of the additional functionality

Basic regular expressions and extended regular expressions:

Basic Regular Expressions: grep

Extended Regular expression: grep-e

Matching mechanism:

1. Match any single character:.

#grep "B.. T "/etc/passwd

#grep--color=auto ' r. T '/etc/passwd

2. Number of occurrences: used to specify the number of occurrences of the preceding character

*: Any time

Example: X*y: Matches with the following several, such as {xxy,xy,y} * before the x can appear once, two times, multiple or 0 times

. *: Any character of any length

\?: matches the preceding character 0 or 1 times

X\?y: There are a few of the following, such as {Xy,y,xxy}, that satisfy the match

Match pattern to greedy mode

\{m\}: Matches M-Times

\{m,n\}: At least m times, up to N times

\{m,\}: At least m times

\{0,n\}: Up to n times

15. Self-Learning Linux path: Text Processing tools Grep,eprep and Fgrep

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.