(004) Linux shell wildcard

Source: Internet
Author: User
Tags character classes uppercase letter

Fundamentals of the ten-year OPS series-Linux

Zeng Lin

Contact: [Email protected]

Website: www.jplatformx.com

Copyright: Please do not reprint the article without permission

First, Introduction

We often have to execute command-line programs under the shell, and these command-line programs often use filenames, so the shell provides special characters to help you quickly specify or filter a set of filenames. These special characters are referred to as "wildcards". Wildcards (also known as file name substitution) allow the user to select a file name based on a character pattern. Wildcard characters can be used with any command that uses a file name parameter. and wildcard characters can not only work in the command-line program, but also in the GUI program.

Second, wildcard characters

The following table provides common wildcard characters, wildcard character classes, and instances in which wildcards are used in practice.

Wildcard character Descriptor:

Wildcard characters Matching items
* Matches any number of characters (including 0 and 1)
? Match any single character (not including 0)
[Characters] Match any character that belongs to a character set
[!characters] Match any character that is not part of a character set
[[: Class:]] Match any of the characters that belong to the specified character class

Wildcard character class table:

Character class Matching items
[: Alnum:] Match any one letter or number
[: Alpha:] Match any one character
[:d Igit:] Match any number
[: Lower:] Match any one lowercase letter
[: Upper:] Match any one uppercase letter

Examples of wildcard characters:

Form Matching items
g* Any file that begins with G
B*.txt Any file beginning with B with any number of characters in the middle and ending in. txt
Data??? Any file that starts with data, followed by a 3 character
[abc]* Any file that begins with either of the ABC
BACKUP. [0-9] [0-9] [0-9] Start with backup. Any file that is immediately followed by a 3-digit number
[[: upper:]]* Any file that begins with an uppercase letter
[! [:d Igit:]] * Any file that does not start with a number
*[[:LOWER:]123] Any file that ends in lowercase letters or numbers 1, 2, 3

(004) Linux shell wildcard

Related Article

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.