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