Wildcard Specifications

One aspect of file manipulation in Linux is the use of wildcards, which are special characters or character groups that stand in for other characters. Using wildcards, you can tell the system to operate on a large number of files that meet certain name criteria. Table 5.1 summarizes some of the most common wildcards.

Table 5.1: Common Wildcards in File Operations

Wildcard

Meaning

*

Any collection of zero or more characters.

?

Any single character.

[ABC]

Any character from the specified set, ABC, of characters, whereABC can be any collection of characters, of any length.

[A-C]

Any character from the set of characters between A and C in the character set.

You can combine wildcards in various ways. For instance, *.[co] matches any filename that ends in .c or .o, such as inet.c or load.o; but not names that end in any other string, such as sound.h. Wildcards are expanded by the shell; therefore, programs called from a shell and passed wildcards as arguments actually receive the complete list of matching files as arguments, not the wildcard.

0 0

Post a comment