15 The fnmatch() function matches patterns as described on the fnmatch(5)
16 manual page. It checks the string argument to see if it matches the
17 pattern argument.
18
19
20 The flags argument modifies the interpretation of pattern and string.
21 It is the bitwise inclusive OR of zero or more of the following flags
22 defined in the header <fnmatch.h>.
23
24 FNM_PATHNAME
25 If set, a slash (/) character in string will be
26 explicitly matched by a slash in pattern; it will not
27 be matched by either the asterisk (*) or question-mark
28 (?) special characters, nor by a bracket ([])
29 expression.
30
31 If not set, the slash character is treated as an
32 ordinary character.
33
34
35 FNM_NOESCAPE
36 If not set, a backslash character (\) in pattern
37 followed by any other character will match that
38 second character in string. In particular, "\\" will
39 match a backslash in string.
40
41 If set, a backslash character will be treated as an
42 ordinary character.
43
44
45 FNM_PERIOD
46 If set, a leading period in string will match a
47 period in pattern; where the location of "leading" is
48 indicated by the value of FNM_PATHNAME:
49
50 o If FNM_PATHNAME is set, a period is
51 "leading" if it is the first character in
52 string or if it immediately follows a
53 slash.
54
55 o If FNM_PATHNAME is not set, a period is
56 "leading" only if it is the first
57 character of string.
58
59
60
61 If not set, no special restrictions are placed on matching a period.
62
63 RETURN VALUES
64 If string matches the pattern specified by pattern, then fnmatch()
65 returns 0. If there is no match, fnmatch() returns FNM_NOMATCH, which
66 is defined in the header <fnmatch.h>. If an error occurs, fnmatch()
67 returns another non-zero value.
68
69 USAGE
70 The fnmatch() function has two major uses. It could be used by an
71 application or utility that needs to read a directory and apply a
72 pattern against each entry. The find(1) utility is an example of this.
73 It can also be used by the pax(1) utility to process its pattern
74 operands, or by applications that need to match strings in a similar
75 manner.
76
77
78 The name fnmatch() is intended to imply filename match, rather than
79 pathname match. The default action of this function is to match
80 filenames, rather than path names, since it gives no special
81 significance to the slash character. With the FNM_PATHNAME flag,
82 fnmatch() does match path names, but without tilde expansion, parameter
93
94
95
96
97 +--------------------+-------------------------+
98 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
99 +--------------------+-------------------------+
100 |CSI | Enabled |
101 +--------------------+-------------------------+
102 |Interface Stability | Standard |
103 +--------------------+-------------------------+
104 |MT-Level | MT-Safe with exceptions |
105 +--------------------+-------------------------+
106
107 SEE ALSO
108 find(1), pax(1), glob(3C), setlocale(3C), wordexp(3C), attributes(5),
109 fnmatch(5), standards(5)
110
111
112
113 July 24, 2002 FNMATCH(3C)
|
15 The fnmatch() function matches patterns as described on the fnmatch(5)
16 manual page. It checks the string argument to see if it matches the
17 pattern argument.
18
19
20 The flags argument modifies the interpretation of pattern and string.
21 It is the bitwise inclusive OR of zero or more of the following flags
22 defined in the header <fnmatch.h>.
23
24 FNM_PATHNAME
25 If set, a slash (/) character in string will be
26 explicitly matched by a slash in pattern; it will not
27 be matched by either the asterisk (*) or question-mark
28 (?) special characters, nor by a bracket ([])
29 expression.
30
31 If not set, the slash character is treated as an
32 ordinary character.
33
34
35 FNM_IGNORECASE
36 If set, the string will be transliterated to lower
37 case before doing the actual match. This
38 transliteration is done using towlower_l(3C), using
39 the locale of the current thread. If no locale is
40 set, then the global locale is used instead.
41
42 If not set, the match will use string with no
43 changes, making the match case-sensitive.
44
45
46 FNM_NOESCAPE
47 If not set, a backslash character (\) in pattern
48 followed by any other character will match that
49 second character in string. In particular, "\\" will
50 match a backslash in string.
51
52 If set, a backslash character will be treated as an
53 ordinary character.
54
55
56 FNM_PERIOD
57 If set, a leading period in string will match a
58 period in pattern; where the location of "leading" is
59 indicated by the value of FNM_PATHNAME:
60
61 o If FNM_PATHNAME is set, a period is
62 "leading" if it is the first character in
63 string or if it immediately follows a
64 slash.
65
66 o If FNM_PATHNAME is not set, a period is
67 "leading" only if it is the first
68 character of string.
69
70
71 If not set, no special restrictions are placed on
72 matching a period.
73
74 RETURN VALUES
75 If string matches the pattern specified by pattern, then fnmatch()
76 returns 0. If there is no match, fnmatch() returns FNM_NOMATCH, which
77 is defined in the header <fnmatch.h>. If an error occurs, fnmatch()
78 returns another non-zero value.
79
80 USAGE
81 The fnmatch() function has two major uses. It could be used by an
82 application or utility that needs to read a directory and apply a
83 pattern against each entry. The find(1) utility is an example of this.
84 It can also be used by the pax(1) utility to process its pattern
85 operands, or by applications that need to match strings in a similar
86 manner.
87
88
89 The name fnmatch() is intended to imply filename match, rather than
90 pathname match. The default action of this function is to match
91 filenames, rather than path names, since it gives no special
92 significance to the slash character. With the FNM_PATHNAME flag,
93 fnmatch() does match path names, but without tilde expansion, parameter
104
105
106
107
108 +--------------------+-------------------------+
109 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
110 +--------------------+-------------------------+
111 |CSI | Enabled |
112 +--------------------+-------------------------+
113 |Interface Stability | Standard |
114 +--------------------+-------------------------+
115 |MT-Level | MT-Safe with exceptions |
116 +--------------------+-------------------------+
117
118 SEE ALSO
119 find(1), pax(1), glob(3C), setlocale(3C), wordexp(3C), attributes(5),
120 fnmatch(5), standards(5)
121
122
123
124 June 6, 2015 FNMATCH(3C)
|