Info Node: (tar.info)wildcards

tar.info: wildcards
Choosing
quoting styles
exclude
Back to Software Index
6.5 Wildcards Patterns and Matching
===================================
"Globbing" is the operation by which "wildcard" characters, `*' or `?'
for example, are replaced and expanded into all existing files matching
the given pattern. GNU `tar' can use wildcard patterns for matching
(or globbing) archive members when extracting from or listing an
archive. Wildcard patterns are also used for verifying volume labels
of `tar' archives. This section has the purpose of explaining wildcard
syntax for `tar'.
A PATTERN should be written according to shell syntax, using wildcard
characters to effect globbing. Most characters in the pattern stand
for themselves in the matched string, and case is significant: `a' will
match only `a', and not `A'. The character `?' in the pattern matches
any single character in the matched string. The character `*' in the
pattern matches zero, one, or more single characters in the matched
string. The character `\' says to take the following character of the
pattern _literally_; it is useful when one needs to match the `?', `*',
`[' or `\' characters, themselves.
The character `[', up to the matching `]', introduces a character
class. A "character class" is a list of acceptable characters for the
next single character of the matched string. For example, `[abcde]'
would match any of the first five letters of the alphabet. Note that
within a character class, all of the "special characters" listed above
other than `\' lose their special meaning; for example, `[-\\[*?]]'
would match any of the characters, `-', `\', `[', `*', `?', or `]'.
(Due to parsing constraints, the characters `-' and `]' must either
come _first_ or _last_ in a character class.)
If the first character of the class after the opening `[' is `!' or
`^', then the meaning of the class is reversed. Rather than listing
character to match, it lists those characters which are _forbidden_ as
the next single character of the matched string.
Other characters of the class stand for themselves. The special
construction `[A-E]', using an hyphen between two letters, is meant to
represent all characters between A and E, inclusive.
Periods (`.') or forward slashes (`/') are not considered special
for wildcard matches. However, if a pattern completely matches a
directory prefix of a matched string, then it matches the full matched
string: thus, excluding a directory also excludes all the files beneath
it.
controlling pattern-matching-
automatically generated by info2www version 1.2