1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified Sat Jul 24 19:35:54 1993 by Rik Faith (faith@cs.unc.edu)
26 .\" Modified Mon Oct 16 00:16:29 2000 following Joseph S. Myers
28 .TH FNMATCH 3 2019-03-06 "GNU" "Linux Programmer's Manual"
30 fnmatch \- match filename or pathname
33 .B #include <fnmatch.h>
35 .BI "int fnmatch(const char *" "pattern" ", const char *" string ", int " flags );
40 function checks whether the
44 argument, which is a shell wildcard pattern (see
49 argument modifies the behavior; it is the bitwise OR of zero or more
50 of the following flags:
53 If this flag is set, treat backslash as an ordinary character,
54 instead of an escape character.
57 If this flag is set, match a slash in
61 and not by an asterisk (*) or a question mark (?) metacharacter,
62 nor by a bracket expression ([]) containing a slash.
65 If this flag is set, a leading period in
67 has to be matched exactly by a period in
69 A period is considered to be leading if it is the first character in
73 is set and the period immediately follows a slash.
76 This is a GNU synonym for
80 If this flag (a GNU extension) is set, the pattern is considered to be
81 matched if it matches an initial segment of
83 which is followed by a slash.
84 This flag is mainly for the internal
85 use of glibc and is implemented only in certain cases.
88 If this flag (a GNU extension) is set, the pattern is matched
92 If this flag (a GNU extension) is set, extended patterns are
93 supported, as introduced by \&'ksh' and now supported by other shells.
94 The extended format is as follows, with \fIpattern\-list\fR
95 being a \&'|' separated list of patterns.
97 \&'?(\fIpattern\-list\fR)'
98 The pattern matches if zero or one occurrences of any of the
99 patterns in the \fIpattern\-list\fR match the input \fIstring\fR.
101 \&'*(\fIpattern\-list\fR)'
102 The pattern matches if zero or more occurrences of any of the
103 patterns in the \fIpattern\-list\fR match the input \fIstring\fR.
105 \&'+(\fIpattern\-list\fR)'
106 The pattern matches if one or more occurrences of any of the
107 patterns in the \fIpattern\-list\fR match the input \fIstring\fR.
109 \&'@(\fIpattern\-list\fR)'
110 The pattern matches if exactly one occurrence of any of the
111 patterns in the \fIpattern\-list\fR match the input \fIstring\fR.
113 \&'!(\fIpattern\-list\fR)'
114 The pattern matches if the input \fIstring\fR cannot be matched with
115 any of the patterns in the \fIpattern\-list\fR.
122 if there is no match or another nonzero value if there is an error.
124 For an explanation of the terms used in this section, see
130 Interface Attribute Value
133 T} Thread safety MT-Safe env locale
136 POSIX.1-2001, POSIX.1-2008, POSIX.2.
138 .BR FNM_FILE_NAME ", " FNM_LEADING_DIR ", and " FNM_CASEFOLD
139 flags are GNU extensions.