1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" Modified Sat Jul 24 19:35:54 1993 by Rik Faith (faith@cs.unc.edu)
6 .\" Modified Mon Oct 16 00:16:29 2000 following Joseph S. Myers
8 .TH FNMATCH 3 2021-03-22 "Linux man-pages (unreleased)"
10 fnmatch \- match filename or pathname
13 .RI ( libc ", " \-lc )
16 .B #include <fnmatch.h>
18 .BI "int fnmatch(const char *" "pattern" ", const char *" string ", int " flags );
23 function checks whether the
27 argument, which is a shell wildcard pattern (see
32 argument modifies the behavior; it is the bitwise OR of zero or more
33 of the following flags:
36 If this flag is set, treat backslash as an ordinary character,
37 instead of an escape character.
40 If this flag is set, match a slash in
44 and not by an asterisk (*) or a question mark (?) metacharacter,
45 nor by a bracket expression ([]) containing a slash.
48 If this flag is set, a leading period in
50 has to be matched exactly by a period in
52 A period is considered to be leading if it is the first character in
56 is set and the period immediately follows a slash.
59 This is a GNU synonym for
63 If this flag (a GNU extension) is set, the pattern is considered to be
64 matched if it matches an initial segment of
66 which is followed by a slash.
67 This flag is mainly for the internal
68 use of glibc and is implemented only in certain cases.
71 If this flag (a GNU extension) is set, the pattern is matched
75 If this flag (a GNU extension) is set, extended patterns are
76 supported, as introduced by \&'ksh' and now supported by other shells.
77 The extended format is as follows, with \fIpattern\-list\fR
78 being a \&'|' separated list of patterns.
80 \&'?(\fIpattern\-list\fR)'
81 The pattern matches if zero or one occurrences of any of the
82 patterns in the \fIpattern\-list\fR match the input \fIstring\fR.
84 \&'*(\fIpattern\-list\fR)'
85 The pattern matches if zero or more occurrences of any of the
86 patterns in the \fIpattern\-list\fR match the input \fIstring\fR.
88 \&'+(\fIpattern\-list\fR)'
89 The pattern matches if one or more occurrences of any of the
90 patterns in the \fIpattern\-list\fR match the input \fIstring\fR.
92 \&'@(\fIpattern\-list\fR)'
93 The pattern matches if exactly one occurrence of any of the
94 patterns in the \fIpattern\-list\fR match the input \fIstring\fR.
96 \&'!(\fIpattern\-list\fR)'
97 The pattern matches if the input \fIstring\fR cannot be matched with
98 any of the patterns in the \fIpattern\-list\fR.
105 if there is no match or another nonzero value if there is an error.
107 For an explanation of the terms used in this section, see
115 Interface Attribute Value
118 T} Thread safety MT-Safe env locale
124 POSIX.1-2001, POSIX.1-2008, POSIX.2.
126 .BR FNM_FILE_NAME ", " FNM_LEADING_DIR ", and " FNM_CASEFOLD
127 flags are GNU extensions.