1fnmatch(3C)              Standard C Library Functions              fnmatch(3C)
2
3
4

NAME

6       fnmatch - match filename or path name
7

SYNOPSIS

9       #include <fnmatch.h>
10
11       int fnmatch(const char *pattern, const char *string, int flags);
12
13

DESCRIPTION

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      If  set,  a  slash  (/)  character  in string will be
25                         explicitly matched by a slash in pattern; it will not
26                         be  matched  by  either the asterisk (*) or question-
27                         mark (?) special characters, nor by  a  bracket  ([])
28                         expression.
29
30                         If  not  set,  the  slash  character is treated as an
31                         ordinary character.
32
33
34       FNM_NOESCAPE      If not set, a backslash character (\) in pattern fol‐
35                         lowed  by  any other character will match that second
36                         character in string. In particular, "\\" will match a
37                         backslash in string.
38
39                         If  set,  a backslash character will be treated as an
40                         ordinary character.
41
42
43       FNM_PERIOD        If set, a leading  period  in  string  will  match  a
44                         period in pattern; where the location of "leading" is
45                         indicated by the value of FNM_PATHNAME:
46
47                             o      If FNM_PATHNAME is set, a period is "lead‐
48                                    ing"  if  it  is  the  first  character in
49                                    string or  if  it  immediately  follows  a
50                                    slash.
51
52                             o      If  FNM_PATHNAME  is  not set, a period is
53                                    "leading" only if it is the first  charac‐
54                                    ter of string.
55
56
57
58       If not set, no special restrictions are placed on matching a period.
59

RETURN VALUES

61       If  string  matches  the  pattern  specified by pattern, then fnmatch()
62       returns 0. If there is no match, fnmatch() returns  FNM_NOMATCH,  which
63       is  defined  in  the  header <fnmatch.h>. If an error occurs, fnmatch()
64       returns another non-zero value.
65

USAGE

67       The fnmatch() function has two major uses.  It  could  be  used  by  an
68       application  or utility that needs to read a directory and apply a pat‐
69       tern against each entry. The find(1) utility is an example of this.  It
70       can also be used by the pax(1) utility to process its pattern operands,
71       or by applications that need to match strings in a similar manner.
72
73
74       The name fnmatch() is intended to imply  filename  match,  rather  than
75       pathname  match.  The default action of this function is to match file‐
76       names, rather than path names, since it gives no  special  significance
77       to  the  slash  character.  With  the FNM_PATHNAME flag, fnmatch() does
78       match path names, but without tilde expansion, parameter expansion,  or
79       special treatment for period at the beginning of a filename.
80
81
82       The  fnmatch()  function  can  be used safely in multithreaded applica‐
83       tions, as long as setlocale(3C) is  not  being  called  to  change  the
84       locale.
85

ATTRIBUTES

87       See attributes(5) for descriptions of the following attributes:
88
89
90
91
92       ┌─────────────────────────────┬─────────────────────────────┐
93       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
94       ├─────────────────────────────┼─────────────────────────────┤
95       │CSI                          │Enabled                      │
96       ├─────────────────────────────┼─────────────────────────────┤
97       │Interface Stability          │Standard                     │
98       ├─────────────────────────────┼─────────────────────────────┤
99       │MT-Level                     │MT-Safe with exceptions      │
100       └─────────────────────────────┴─────────────────────────────┘
101

SEE ALSO

103       find(1),  pax(1),  glob(3C), setlocale(3C), wordexp(3C), attributes(5),
104       fnmatch(5), standards(5)
105
106
107
108SunOS 5.11                        24 Jul 2002                      fnmatch(3C)
Impressum