Filename Substitution (Globbing)
The most common type of substitution is filename substitution or globbing. Globbing is the method by which the shell expands a string containing globbing meta-characters or wildcards into a list of filenames. Table 9.1 lists the wildcards used in globbing.
Wildcard | Description |
---|---|
* | Matches zero or more occurrences of any character |
? | Matches one occurrence of any character |
[characters] | Matches one occurrence of any of the given characters |
Any command or script that operates on files can take advantage of globbing. The examples in this section use the ls command because its output clearly illustrates the results of globbing.
The * Meta-Character
The simplest form of filename ...
Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.