Linux wildcard characters

Source: Internet
Author: User

Shell wildcard characters
The difference between wildcard characters and regular expressions
1. Different use
Wildcards are used for wildcard filenames, and regular expressions are used to match text content
2. Different places of Use
Wildcards are usually used only for shells, and are interpreted by the shell itself.
Regular expressions need to be parsed by the regular engine and need to be used in code or commands that support regular expressions.
3, meta-characters are different
Wildcard characters are only three metacharacters, and regular expressions vary depending on the regular engine.
Also, the meaning of the same meta-character representation may be different. such as a wildcard matches any character, in regularIndicates that the preceding character repeats 0 or any time.

*   匹配 0 或多个字符  a*b  a与b之间可以有任意长度的任意字符, 也可以一个也没有, 如aabcb, axyzb, a012b, ab。?    匹配任意一个字符   a?b  a与b之间必须也只能有一个字符, 可以是任意字符, 如aab, abb, acb, a0b。[list]  匹配 list 中的任意单一字符    a[xyz]b   a与b之间必须也只能有一个字符, 但只能是 x 或 y 或 z, 如: axb, ayb, azb。[!list]     匹配 除list 中的任意单一字符   a[!0-9]b  a与b之间必须也只能有一个字符, 但不能是阿拉伯数字, 如axb, aab, a-b。[c1-c2] 匹配 c1-c2 中的任意单一字符 如:[0-9] [a-z] a[0-9]b  0与9之间必须也只能有一个字符 如a0b, a1b... a9b。{string1,string2,...}   匹配 sring1 或 string2 (或更多)其一字符串  a{abc,xyz,123}b    a与b之间只能是abc或xyz或123这三个字符串之一。

Special Pass
Range Matching:

[0-9]:表示匹配数字[a-z]:表示匹配小写字母[A-Z]:表示匹配大写字母

Range matching Inverse:

[^0-9]:表示匹配非数字``[^a-z]:表示匹配非小写字母`[^A-Z]:表示匹配非大写字母

Special Matching method:

[[:space:]]:表示匹配空白字符[[:punct:]]:表示匹配标点符号[[:digit:]]:表示匹配数字[[:lower:]]:表示匹配小写字母[[:upper:]]:表示匹配大写字母[[:alpha:]]:表示匹配字母,不区分大小写[[:alnum:]]:表示匹配字母数字。

The special matching method also supports inversion, which is reversed as follows:
[^[::]]

Linux wildcard characters

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.