Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

1.16 Wildcards

Wildcards are utilized within the shell environment to match specified character ranges. The most frequently encountered wildcards are defined below:

SymbolArchitectural Meaning / Matching Pattern
*Matches zero or more arbitrary characters.
?Matches exactly one single arbitrary character.
[]Matches any one single character enclosed within the brackets (defines a range or set).

Examples:

$ ls *.c

$ ls file?.txt

Bracket Range Matching

PatternMatching Envelope Rules
[character_set]Matches any single character present within the specified set.
[character-character]Matches any single character falling within the sequential range defined by the hyphen boundaries.
[!character_set]Matches any single character not included within the specified set.
[^character_set]Anchors the pattern to match strings that begin with the character configurations specified.

Examples:

$ ls file[123].txt

Valid matches:

  • file1.txt

  • file2.txt

  • file3.txt

Invalid matches (will not match):

  • file12.txt
$ ls file[a-z].txt

Valid matches:

  • filea.txt

  • fileb.txt

  • ...

  • filez.txt

Standard Character Range Configurations

ConfigurationExplicit Matching Context Syntax
[a-z]All lowercase alphabetic characters.
[A-Z]All uppercase alphabetic characters.
[0-9]All single-digit numeric characters.
[a-zA-Z]All alphabetic characters regardless of case.
[a-z0-9]All lowercase alphanumeric characters.
Copyright © 2026 Guangzhou eSmart Information Technology Co., Ltd. All Rights Reserved.
All content in this book is copyrighted by the author. For personal learning and exchange only. Commercial use without authorization is strictly prohibited. Email:

✉ 3348194517@qq.com | hai616878@gmail.com