Linux basic--grep and regular expressions

Source: Internet
Author: User
Tags expression engine egrep

The basic usage of grep can be referred to in this [link] document, written in detail, here is the main description of the use of regular expressions.


    1. GREP supports the basic regular Expressions (BRE) and extended regular Expressions (ERE) by default.

    2. Fgrep does not support regular expressions and does not need to load the regular expression engine, so it is faster.

    3. The Egrep only supports extended regular expressions (ERE).

    4. ' Egrep ' means ' grep-e '. ' Fgrep ' means ' grep-f '.


The extended regular expression (ERE) differs from the basic regular expression (BRE), and the matching rules in the BRE also apply in the Ere, but ere the use of some meta-characters and symbols without the ' \ ' escape, and Ere adds a ' | ' The symbol represents the logical OR.

So it is not intended to introduce the BRE and Ere separately, the following does not indicate the use of ere separately, the description is consistent with the BRE usage.


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7D/01/wKiom1beVinCrWsrAABZfIxu7Wo939.png "title=" Grep_ 001.png "width=" height= "131" border= "0" hspace= "0" vspace= "0" style= "width:700px;height:131px;" alt= " Wkiom1bevincrwsraabzfixu7wo939.png "/>


650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7D/01/wKiom1beVsaTt5X8AADJSJpgzR0610.png "title=" Grep_ 002.png "width=" height= "333" border= "0" hspace= "0" vspace= "0" style= "width:700px;height:333px;" alt= " Wkiom1bevsatt5x8aadjsjpgzr0610.png "/>


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7D/00/wKioL1beWAbgZ1mvAABmBCnvV7o027.png "title=" Grep_ 003.png "width=" height= "141" border= "0" hspace= "0" vspace= "0" style= "width:700px;height:141px;" alt= " Wkiol1bewabgz1mvaabmbcnvv7o027.png "/>


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7D/01/wKiom1beV-ySozPAAABaMXVILW4259.png "title=" Grep_ 004.png "width=" height= "138" border= "0" hspace= "0" vspace= "0" style= "width:700px;height:138px;" alt= " Wkiom1bev-ysozpaaabamxvilw4259.png "/>


650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7D/00/wKioL1beWSzDlf3GAABu-0jW_gE833.png "title=" Grep_ 005.png "Width=" height= "182" border= "0" hspace= "0" vspace= "0" style= "width:700px;height:182px;" alt= " Wkiol1bewszdlf3gaabu-0jw_ge833.png "/>


650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7D/01/wKiom1beWPiSAEA9AAClbbYi6CE907.png "title=" Grep_ 006.png "width=" height= "279" border= "0" hspace= "0" vspace= "0" style= "WIDTH:700PX;HEIGHT:279PX;" alt= " Wkiom1bewpisaea9aaclbbyi6ce907.png "/>


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7D/00/wKioL1beWiCSJ3byAABwkPb_Bkc471.png "title=" Grep_ 007.png "width=" height= "188" border= "0" hspace= "0" vspace= "0" style= "width:700px;height:188px;" alt= " Wkiol1bewicsj3byaabwkpb_bkc471.png "/>


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7D/01/wKiom1beWfSCu2LuAAF4CeMxuPg846.png "title=" Grep_ 008.png "width=" height= "631" border= "0" hspace= "0" vspace= "0" style= "width:700px;height:631px;" alt= " Wkiom1bewfscu2luaaf4cemxupg846.png "/>


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7D/00/wKioL1beW5Lgrd8qAABsIQ9wG3k139.png "title=" Grep_ 009.png "width=" height= "167" border= "0" hspace= "0" vspace= "0" style= "WIDTH:700PX;HEIGHT:167PX;" alt= " Wkiol1bew5lgrd8qaabsiq9wg3k139.png "/>


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7D/01/wKiom1beW2PyKy-AAABSI3gjhrQ067.png "title=" Grep_ 010.png "width=" height= "119" border= "0" hspace= "0" vspace= "0" style= "WIDTH:700PX;HEIGHT:119PX;" alt= " Wkiom1bew2pyky-aaabsi3gjhrq067.png "/>


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7D/00/wKioL1beXEfSgAq9AAB3pPKZDLs828.png "title=" Grep_ 011.png "width=" height= "169" border= "0" hspace= "0" vspace= "0" style= "WIDTH:700PX;HEIGHT:169PX;" alt= " Wkiol1bexefsgaq9aab3ppkzdls828.png "/>


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7D/01/wKiom1beXBfBewO2AABT4V1gTF8700.png "title=" Grep_ 012.png "width=" height= "122" border= "0" hspace= "0" vspace= "0" style= "width:700px;height:122px;" alt= " Wkiom1bexbfbewo2aabt4v1gtf8700.png "/>


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7D/00/wKioL1beXUzS9g5pAABTeYCTFiQ769.png "title=" Grep_ 013.png "width=" height= "122" border= "0" hspace= "0" vspace= "0" style= "width:700px;height:122px;" alt= " Wkiol1bexuzs9g5paabteyctfiq769.png "/>


The above results are generated using this [script] and can be downloaded for validation. The terminal connection tool needs to support the display color and the system character set to Chinese.

[Email protected] ~]# wget https://raw.githubusercontent.com/twoyang0917/LearnInMagedu/master/shell/grep_show.sh [ [Email protected] ~]# bash grep_show.sh


This article is from the "knfprex3a29" blog, make sure to keep this source http://knfprex3a29.blog.51cto.com/9761463/1748712

Linux basic--grep and regular expressions

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.