fnmatch(3C) fnmatch(3C)
NAME
fnmatch - match filename or pattern
SYNOPSIS
#include <fnmatch.h>
int fnmatch(const char *pattern, const char *string, int
flags);
DESCRIPTION
fnmatch checks string to see if it matches the pattern
specified by pattern.
Flags
flags is the bitwise inclusive OR of zero or more of the flags
defined in the fnmatch.h header. It modifies the
interpretation of pattern and string. The following flags can
be set:
FNM_PATHNAME
A slash () character in string is explicitly matched by
a slash in pattern. A slash is not matched by an
asterisk or question mark special character or a bracket
expression. If FNM_PATHNAME is not set, the slash
character is treated as an ordinary character.
FNM_NOESCAPE
A backslash character is treated as an ordinary
character. If FNM_NOESCAPE is not set, a backslash
character in pattern followed by any other character
will match that second character in string. In
particular, ``\\'' will match a backslash in string.
FNM_PERIOD
A leading period in string will match a period in
pattern where the location of ``leading'' is indicated
by the value of FNM_PATHNAME:
If FNM_PATHNAME is set, a period is leading if it
is the first character in string or if it
immediately follows a slash.
If FNM_PATHNAME is not set, a period is leading
only if it is the first character of string.
Copyright 1994 Novell, Inc. Page 1
fnmatch(3C) fnmatch(3C)
If FNM_PERIOD is not set, then no special restrictions
are placed on matching a period.
Return Values
fnmatch returns zero if string matches pattern. If there is
no match, fnmatch returns FNM_NOMATCH, which is defined in
fnmatch.h. fnmatch returns another non-zero value on error.
USAGE
The name fnmatch indicates that this function is intended to
match filenames rather than pathnames. With FNM_PATHNAME,
fnmatch matches pathnames, but without tilde expansion,
parameter expansion, or special treatment for a period at the
beginning of a filename.
REFERENCES
fnmatch(5), glob(3C), wordexp(3C).
Copyright 1994 Novell, Inc. Page 2