fnmatch(3C)fnmatch(3C)NAMEfnmatch() - match filename patterns
SYNOPSISDESCRIPTION
performs pattern matching as described in regexp(5) under By default,
the rule qualifications for filename expansion do not apply; i.e.,
periods (dots) and slashes are matched as ordinary characters. This
default behavior can be modified by using the flags described below.
The flag argument modifies the interpretation of pattern and string.
If which is defined in is set in flag, a slash character in string must
be explicitly matched by a slash in pattern; it cannot be matched by
either the asterisk or question mark special characters or by a bracket
expression.
If is set in flag, a leading period must be explicitly matched. It
will not be matched by a bracket expression, question mark or asterisk.
By default, a period is leading if it is the first character in string.
If is set in flag, a period is leading if it is the first character in
string or immediately follows a slash.
If is not set in flag, a backslash character in pattern followed by any
other character matches that second character in string. In particu‐
lar, matches a backslash in string. If is set, a backslash character
is treated as an ordinary character.
If flag is zero, the slash character and the period are treated as reg‐
ular characters. If flag has any other value, the result is undefined.
RETURN VALUE
If string matches the pattern specified by pattern, returns zero. Oth‐
erwise, returns non-zero.
EXAMPLE
The following excerpt uses to check each file in a directory against
the pattern
pattern = "*.c";
while(dp = readdir(dirp)){
if((fnmatch(pattern, dp->d_name,0)) == 0){
/* do processing for match */
...
}
}
AUTHOR
was developed by OSF and HP.
SEE ALSOsh(1), glob(3C), thread_safety(5).
STANDARDS CONFORMANCEfnmatch(3C)