Wildcard characters in Linux endpoints

Source: Internet
Author: User
Tags touch command

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

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.