Linux file name wildcard

Source: Internet
Author: User

A wildcard is a special statement used to blur the search for a file. When looking for a folder or directory, you can use it instead of one or more real characters

Wildcard characters:
*: matches any character of any length (packet 0 characters)

        [[email protected] tt]# ls                 ab  abb  abc   abm  xab  #  If you have documents         [[email  protected] tt]# ls ab*             ab  abb  abc  abm    #  match with AB start followed by any character          [[email protected] tt]# ls *ab             ab  xab               #  match with AB end          [[email protected] tt]# ls *ab*             ab  abb  abc  abm  xab     #匹配包含ab的文件 

? : Matches any single character

[[email protected] tt]# ls a? Ab

[ ]: matches any single character within the specified range of characters, the wildcard itself is not case-sensitive.

[XYZ] # match XYZ [A-z] # match A-Z letter set [A-z] # match uppercase set [0-9] # match number [0-9a-za-z] # match Digit case letters [[email protected] tmp]# ls a[0-9]* a1b a2b a3b a4b a5b a6b a7b a8b a9b

It is recommended to use the Posi specification to match, as the following character set can be case-sensitive
[[: Upper:]]All uppercase letters
[[: Lower:]]lowercase letters
[[: Alpha:]]Uppercase and lowercase letters set
[[:d igit:]]Digital
[[: Alnum:]]Contains numbers and alphabet
[[: Space:]]Space
[[:p UNCT:]]Punctuation


[^]: Matches any single character that is outside the specified range of characters to match the inverse of

[[email protected] tmp]# rm-rf./[^my]* # Delete the file in the current directory that is not the beginning of my, followed by the * number to indicate the end of whatever
[^0-9] # any character other than a number [^[:d igit:]] # If it's a character set, use this notation

This article is from "Rookie Diary" blog, please make sure to keep this source http://zkxfoo.blog.51cto.com/1605971/1660755

Linux file name wildcard

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.