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.
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
77       another nonzero value if there is an error.
78

ATTRIBUTES

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

CONFORMING TO

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

SEE ALSO

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

COLOPHON

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