1FNMATCH(3)                 Linux Programmer's Manual                FNMATCH(3)
2
3
4

NAME

6       fnmatch - match filename or pathname
7

SYNOPSIS

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

DESCRIPTION

14       The  fnmatch()  function checks whether the string argument matches the
15       pattern argument, which is a shell wildcard pattern (see glob(7)).
16
17       The flags argument modifies the behavior; it is the bitwise OR of  zero
18       or more of the following flags:
19
20       FNM_NOESCAPE
21              If  this  flag is set, treat backslash as an ordinary character,
22              instead of an escape character.
23
24       FNM_PATHNAME
25              If this flag is set, match a slash in string only with  a  slash
26              in  pattern  and  not  by an asterisk (*) or a question mark (?)
27              metacharacter, nor by a bracket  expression  ([])  containing  a
28              slash.
29
30       FNM_PERIOD
31              If  this  flag  is  set,  a  leading  period in string has to be
32              matched exactly by a period in pattern.  A period is  considered
33              to be leading if it is the first character in string, or if both
34              FNM_PATHNAME is set and the period immediately follows a slash.
35
36       FNM_FILE_NAME
37              This is a GNU synonym for FNM_PATHNAME.
38
39       FNM_LEADING_DIR
40              If this flag (a GNU extension) is set, the pattern is considered
41              to  be  matched if it matches an initial segment of string which
42              is followed by a slash.  This flag is mainly  for  the  internal
43              use of glibc and is implemented only in certain cases.
44
45       FNM_CASEFOLD
46              If  this  flag  (a GNU extension) is set, the pattern is matched
47              case-insensitively.
48
49       FNM_EXTMATCH
50              If this flag (a GNU extension) is  set,  extended  patterns  are
51              supported,  as  introduced  by  'ksh' and now supported by other
52              shells.  The extended format is as  follows,  with  pattern-list
53              being a '|' separated list of patterns.
54
55       '?(pattern-list)'
56              The  pattern  matches  if  zero or one occurrences of any of the
57              patterns in the pattern-list match the input string.
58
59       '*(pattern-list)'
60              The pattern matches if zero or more occurrences of  any  of  the
61              patterns in the pattern-list match the input string.
62
63       '+(pattern-list)'
64              The  pattern  matches  if  one or more occurrences of any of the
65              patterns in the pattern-list match the input string.
66
67       '@(pattern-list)'
68              The pattern matches if exactly one occurrence of any of the pat‐
69              terns in the pattern-list match the input string.
70
71       '!(pattern-list)'
72              The  pattern  matches if the input string cannot be matched with
73              any of the patterns in the pattern-list.
74

RETURN VALUE

76       Zero if string matches pattern, FNM_NOMATCH if there is no match or an‐
77       other nonzero value if there is an error.
78

ATTRIBUTES

80       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
81       tributes(7).
82
83       ┌─────────────────────────────────┬───────────────┬────────────────────┐
84Interface                        Attribute     Value              
85       ├─────────────────────────────────┼───────────────┼────────────────────┤
86fnmatch()                        │ Thread safety │ MT-Safe env locale │
87       └─────────────────────────────────┴───────────────┴────────────────────┘
88

CONFORMING TO

90       POSIX.1-2001,  POSIX.1-2008,  POSIX.2.   The  FNM_FILE_NAME,  FNM_LEAD‐
91       ING_DIR, and FNM_CASEFOLD flags are GNU extensions.
92

SEE ALSO

94       sh(1), glob(3), scandir(3), wordexp(3), glob(7)
95

COLOPHON

97       This  page  is  part of release 5.13 of the Linux man-pages project.  A
98       description of the project, information about reporting bugs,  and  the
99       latest     version     of     this    page,    can    be    found    at
100       https://www.kernel.org/doc/man-pages/.
101
102
103
104GNU                               2021-03-22                        FNMATCH(3)
Impressum