1 .\" $OpenBSD: glob.7,v 1.3 2009/12/26 15:24:54 schwarze Exp $
3 .\" Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 .Dd $Mdocdate: December 26 2009 $
23 .Nd shell-style pattern matching
27 are special characters used to perform pattern matching of pathnames and
28 command arguments in the
34 the C library functions
38 A glob pattern is a word containing one or more unquoted
46 Globs should not be confused with the more powerful
47 regular expressions used by programs such as
49 While there is some overlap in the special characters used in regular
50 expressions and globs, their meaning is different.
52 The pattern elements have the following meaning:
55 Matches any single character.
57 Matches any sequence of zero or more characters.
59 Matches any of the characters inside the brackets.
60 Ranges of characters can be specified by separating two characters by a
67 In order to represent itself, a
69 must either be quoted or the first or last character in the character list.
72 must be quoted or the first character in the list if it is to represent itself
73 instead of the end of the list.
76 appearing at the start of the list has special meaning (see below), so to
77 represent itself it must be quoted or appear later in the list.
79 Within a bracket expression, the name of a
85 stands for the list of all characters belonging to that class.
86 Supported character classes:
87 .Bl -column "xdigit" "xdigit" "xdigit" -offset indent
88 .It Li "alnum" Ta "cntrl" Ta "lower" Ta "space"
89 .It Li "alpha" Ta "digit" Ta "print" Ta "upper"
90 .It Li "blank" Ta "graph" Ta "punct" Ta "xdigit"
93 These match characters using the macros specified in
95 A character class may not be used as an endpoint of a range.
98 except it matches any character not inside the brackets.
100 Matches the character following it verbatim.
101 This is useful to quote the special characters
107 such that they lose their special meaning.
108 For example, the pattern
109 .Dq \e\e\e\&*\e[x]\e\&?
114 Note that when matching a pathname, the path separator
126 .Pa /usr/X11R6/lib/X11
128 .Pa /usr/X11R6/include/X11
131 would not match either.
145 the shell did not do pattern expansion itself.
148 was used to perform the expansion and pass the results to a command.
151 with the introduction of the Bourne shell,
152 this functionality was incorporated into the shell itself.