Linux grep command usage and regular expressions

Source: Internet
Author: User
  1. What is grep

    grep (Global search REgular expression and Printout the line), which is a globally searchable regular expression and prints out matching rows, is a powerful text-search tool in the Linux system that is based on user-specified "patterns ( pattern) "Filters the target text to show rows that are matched by the pattern.

  2. Basic syntax format for grep commands

    grep [Options] PATTERN [FILE ...]

  3. Common options for grep

    -V: Reverse the matching content

    -O: Show only what matches to

    -I: Ignore case

    -N: Show line numbers

    --color=auto: Using colors to display matching content

    The basic usage of grep in conjunction with regular expressions

    .: Any single character

    []: Any single character of the characters contained in parentheses, such as

    Pure numbers: [[:d Igit:]] or [0-9]

    lowercase letters: [[: Lower:]] or [A-z]

    Capital letters: [[: Upper:]] or [A-z]

    Uppercase and lowercase letters: [[: Alpha:]] or [a-za-z]

    Numbers plus letters: [[: Alnum:]] or [0-9a-za-z]

    whitespace characters: [[: Space:]]

    Punctuation: [[:p UNCT:]]


Linux grep command usage 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.