Small Kee Linux Regular expressions

Source: Internet
Author: User

Regular expression grep cut sort Uniq

A regular expression is a representation that allows you to find text that matches a specific criterion.

. Matches any single character, except for null

* Match any number of individual characters before it

. * represents any length that matches any one character

^ matches the preceding regular expression, at the beginning of the string or line

$ matches the preceding regular expression, at the end of the string or line

[] match any character in square brackets ^ symbol in square brackets the first character has the opposite meaning: it refers to any character that is not in the list

\{n,m\} interval expression that matches the number of times that a single character in front of it is reproduced. \{n\} is reproduced n times, \{n,\} reproduces at least n times, and \{n,m\} is reproduced n to M times

\ (\) stores the pattern between \ (and \) in a special reserved space. Finally, 9 separate sub-patterns can be stored in a single pattern. Text that matches the sub-pattern can be reused in the same pattern by escaping sequences \1 through \9.

\ n repeats the pattern in the \ (\ and) square brackets in the nth child mode to this point.

{n,m}, like \{n,m\}, is used in an extended regular expression except that there are no backslashes before the square brackets

+ Match one or more instances of the preceding regular expression in an extended regular expression

? Matches 0 or 1 instances of the preceding regular expression in an extended regular expression

| Match to | Regular expressions before or after a symbol are used in an extended regular expression

() a regular expression group matched to the expanded square brackets is used in the extended regular expression

Character:

[: Alnum:] Numeric characters

[: Alpha:] Alphabetic character

[: Blank:] spaces and positional characters

[:d Igit;] numeric characters

[: Lower:] Lowercase alphabetic characters

[:p UNCT:] punctuation characters

[: Space:] white space characters

[: Upper:] Uppercase characters

Grep finds the full-text search regular expression and prints it, matches the entire pattern from the file, and then displays the rows that contain the matched content

GREP-V Reverse Display

Grep-n shows only the number of rows entered in the matching result

Grep-i ignoring case

GREP-E can find multiple content

Grep-an matches the n rows to the following rows

GREP-BN matches n rows to the front of the row

GREP-CN up and down n rows

Grep-e using an extended regular expression to match

Cut takes the content in segments and columns

Cut-d: separated by a colon

CUT-F1 First Line

Cut-c2-6 第2-6个 Characters

Sort sorted (no effect on source file, want to save with pipe or Sort-o file name)

Sort defaults to string sorting

SORT-R reverse Order

Sort-n Sort By value

Sort-f ignoring case

Sort-u to remove duplicate rows after sorting

Uniq to remove duplicate rows

Uniq-c can show the number of times each row has been duplicated

Uniq-u Show only rows that are not duplicates

Uniq-d only duplicate rows are displayed

Sed Line Editor

Sed-s replaces only the first plus g of the source file for each replacement

Sed Start position End position/ /G

Sed-i Replacing source files

SED-E simultaneous implementation of multiple application conditions

SED-F option to read a condition from a file

Sed-i ignoring case

Sed a\ inserting text before the current line

sed-d Delete Row i\ insert text before the current line


Small Kee Linux 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.