Copyright (C) 2000-2012 |
GNU Info (tar.info)WildcardsWildcards 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. However, `tar' often uses wildcard patterns for matching (or globbing) archive members instead of actual files in the filesystem. 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: excluding a directory also excludes all the files beneath it. There are some discussions floating in the air and asking for modifications in the way GNU `tar' accomplishes wildcard matches. We perceive any change of semantics in this area as a delicate thing to impose on GNU `tar' users. On the other hand, the GNU project should be progressive enough to correct any ill design: compatibility at all price is not always a good attitude. In conclusion, it is _possible_ that slight amendments be later brought to the previous description. Your opinions on the matter are welcome. automatically generated by info2www version 1.2.2.9 |