A wildcard is a special statement that has an asterisk (*) and a question mark (?), which is used to make a fuzzy match to a string (such as a file name, parameter name). When you look for a folder, you can use it instead of one or more real characters, and you often use wildcards instead of one or more real characters when you don't know the real characters or are too lazy to enter the full name.
The wildcard character entered in the terminal is handled by the shell, not by the command statement involved, it only appears in the command's "parameter value" (It is not in the command name, the command does not remember, then use tab completion). When the shell encounters a wildcard character in the parameter value, the shell treats it as a path or file name to search for a possible match on disk: If a matching match exists, the substitution (path extension) is performed, otherwise the wildcard character is passed as a normal to "command" and then processed by the command. In short, a wildcard is actually a kind of path extension that the Shell implements. After the wildcard is processed, the shell completes the reorganization of the command before continuing with the reorganized command until the command is executed.
Use the Touch command first to create 2 files with the suffix txt:
$ Touch Adsfasd.txt Wergjlkas.txt
You can give the file a random name, if after a long time, you have forgotten the file name of the two files, and now you want to find the two text files in your large heap of other files, you can use wildcard characters:
$ ls *.txt
When creating a file, if you need to create multiple files at once, for example: "Love_1_linux.txt,love_2_linux.txt, ... love_10_linux.txt". Very handy in Linux:
$ Touch Love_{1..10}_linux.txt
Shell Common wildcard characters:
character |
meaning |
* |
matches 0 or more characters |
|
matches any one character |
[list" |
matches any single character in the list |
[!list" |
match a character other than any single character in the list |
[c1-c2" |
match any single word in c1-c2 such as: [0-9] [A-z] |
{string1,string2,...} |
match sring1 or string2 (or more) one of the strings |
{c2..c2} |
Match all characters in c1-c2 such as {1..10}
|
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Wildcard characters in Linux endpoints