Shell programming for Linux systems-the normal form

Source: Internet
Author: User
Tags egrep


Shell programming is in the form of:

1: meta-character []. *  ?

+ ( )  | {  }  ^  $

2: [a-z0-9] Represents a random number and letter match

3: [^a-z] matches the random one except the letter

4:ab+c + represents a character that matches one or more of the preceding + numbers

5:ab*c * indicates that no or more characters are preceded by the * number

6:ab?c? Represents a match? Character preceding the number

7: (AB) {2}c represents a character that matches two ab characters.

8: (AB) *c (AB) +c (AB)? c the same rules as 4,5,6, just the characters that match all the brackets in the face.

9:^ab matches characters that begin with AB. and [^ab] means that the match except for the character AB

: \<title\> only matches the word title, with a space or newline as the delimiter



fgrep grep egrep command grep in Linux (global regular expression and printing)

The fgrep command does not use the regular form. Match all characters as normal characters at the time of lookup

The grep command supports only normal, regular forms, and does not support the extended regular

The EGREP command supports all extended regularization forms.




Several common ways to use grep:

1:grep-v matches characters not included in the regular table grep-v ' ^ab '/etc/passwd characters that do not start with AB

2:grep--color to mark the matching characters in color

3:grep-o only displays matching characters after filtering.

4:GREP-A2 ' abc '/etc/passwd displays the matching characters and the top two lines of the matching word lines

5:GREP-B2 ' abc '/etc/passwd displays the matching characters and the following two lines of the matching word lines

6:GREP-C3 ' abc '/etc/passwd displays the following and two lines of matching characters and matching word lines

                                                     7:  grep -f/etc/shadow/etc/passwd   includes

in matching/etc/passwd based on content in the/etc/shadow file

                                                                          characters in/etc/shadow

8:GREP-E indicates support for extending the normal form. Equivalent to Egrep

9:











Shell programming for Linux systems-the normal form

Related Article

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.