Shell Regular Expression

Source: Internet
Author: User

One. grep

grep parameters:

- n: Show Line Numbers

- o: Show only matching content

- Q: silent mode, no output, you have to use $? To determine the success of the execution, that is, there is no filtering to the desired content

- L: If the match succeeds, only the file name is printed, the failure is not printed, usually-rl together,grep-rl ' root '/etc

-A: If the match is successful, print the matching line together with the N rows after the period

- b: If the match succeeds, the matching row and the first n rows of the period are printed together

- C: If the match succeeds, print the matching row and the N rows before and after the period

--color

- C: If the match succeeds, the number of rows to match is printed

- e: equals grep, extended

-I: Ignore case

- v: inverse, mismatch

- w: match word

[Email protected] ~123[[email protected]"root"  123 [[email protected]"root"123
Two. Regular introduction

^ beginning of the line

$ End of line

. Any single character other than the line break

* Leading characters of the Spirit song or multiple

. * All characters

[] any character within a character group

[^] reverse each character within a character group (does not match each character in a group of characters)

^[^] lines that begin with characters within a non-character group

[A-z] lowercase Letter

[A-z] capital letters

[A-z] uppercase and lowercase letters

[0-9] number

\< words are usually separated by spaces or special characters, and successive strings are treated as words.

\> Word Tail

Shell Regular Expression

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.