A detailed description of the Linux regular expression

Source: Internet
Author: User

Regular Expressions (REGULAR): A set of rules and methods defined for processing a large number of strings,

Common Command Parameters

Basic Regular Expressions

. : There is only one character (including spaces) *: Repeat any of the preceding 0 or more characters. *: matches any character ==> all, including spaces \: Escape character, let meaningful character, display prototype  \$-  -$ itself ^: ^d  file starting with D $:/$  in/End style ^$: Represents a blank line    grep-vn "^$" h.txt-no blank line-  n displays line number  sed-r ' s# (. *) fff#i am \1#g ' h.txt  just take each Line () Something inside    R==reqular[abc]   matches any character in the character set  [0-9] Match 0-9 [A-z] a-z[^abc]  does not match any character in the character set, which is equivalent to taking anti-a\{n,m} Repeat the previous letter, N to M times       grep "0\{2\}" H.txt  repeat 0 2 times     ==>  egrep "0{2}" h.txt ==>  grep-e "0{2}" H.txt \{n,\} repeats   at least n times \{,m\}   repeat more than m times    Note: egrep, Sed-r filter General special characters can not be escaped \w  : print only the letter    grep "\w" H.txt  --A B c d e F g h i \w  : print non-letter \b  : match the delimiter of the word    grep "\bhello\b" h.txt\d  : Represents a number

Common Command Display

Linux grep/egrep Command Detailed

Linux sed command detailed

Linux awk Command Details

Extended Regular Expression
Extended Regular expression: more for Egrep,grep-e     1. + Repeat one or more of the characters         Grep-eo "Go+d" h.txt--god good     2.? Repeat 0 or one  greater range          Grep-eo "G?d" h.txt---  gd, D          grep-eo "Go?d" h.txt--  gd God      3. | Query multiple conforming strings          Grep-eo "Hello|world"--Hello  World    4. () find the "user group" string         egrep "G (la|oo) d" H.txt-good Glad

Some little knowledge about the regular

1.Linux applies To: Grep,egrep,awk,sed,  2. The difference between the wildcards regular,  such as  ls *.log here is the * represents all 3. Linux is generally in the Behavioral Unit 4. Note Character Set export Lc_all=c  

Detailed description of the Linux 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.