16. Self-Learning Linux path: Text Processing tool Egrep,fgrep

Source: Internet
Author: User
Tags egrep

Egrep: Use an extended regular expression to build the pattern, which is equivalent to GREP-E

  Meta characters :

      Character Matching :

. : Any single character

         []: Specify any single character in the range

        [^]: Any single character outside the specified range

      number of matches :

          *: Matches its preceding character any time

         ?: Match its preceding character 0 or 1 times

+: Match its preceding character 1 or more times

         {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

       anchoring :

         ^: Beginning of the line

         $: End of line

         \<,\b: the first word

         \>,\b: Ending

      Group :

        (): Group

         |: or example: AC|BC, which represents AC or BC, if a (c|b) C, indicates ACC,ABC

Fgrep:fast, do not parse regular expression, need to find what directly in the mode to fill in the corresponding content can be

Practice :

1. Find the line that ends with "LISTEN" or "established" in the results of the Netstat-tan command execution

  #netstat-tan | grep--color=auto-e "listen| Established[[:space:]]* "

  

2. Matching IP address

 #ifconfig | Grep-e--color=auto "(\< ([1-9]|[ 1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]) \>\.) {3} (\< ([0-9]|[ 1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]) \>) "

        

16. Self-Learning Linux path: Text Processing tool Egrep,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.