.\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Guido van Rossum. .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)fnmatch.3 8.3 (Berkeley) 4/28/95 .\" $FreeBSD: src/lib/libc/gen/fnmatch.3,v 1.19.6.1 2008/11/25 02:59:29 kensmith Exp $ .\" .TH FNMATCH 3 "July 18, 2004" .AT 3 .SH NAME fnmatch \- test whether a filename or pathname matches a shell-style pattern .SH SYNOPSIS .nf .ft B #include int fnmatch(const char *\fIpattern\fP, const char *\fIstring\fP, int \fIflags\fP); .ft R .fi .SH DESCRIPTION The .B fnmatch function matches patterns according to the rules used by the shell. It checks the string specified by the .IR string argument to see if it matches the pattern specified by the .IR pattern argument. .PP The .IR flags argument modifies the interpretation of .IR pattern and .IR string . The value of .IR flags is the bitwise inclusive OR of any of the following constants, which are defined in the include file fnmatch.h. .TP 15 FNM_NOESCAPE Normally, every occurrence of a backslash followed by a character in .IR pattern is replaced by that character. This is done to negate any special meaning for the character. If the FNM_NOESCAPE flag is set, a backslash character is treated as an ordinary character. .TP 15 FNM_PATHNAME Slash characters in .IR string must be explicitly matched by slashes in .IR pattern . If this flag is not set, then slashes are treated as regular characters. .TP 15 FNM_PERIOD Leading periods in .IR string must be explicitly matched by periods in .IR pattern . If this flag is not set, then leading periods are treated as regular characters. The definition of leading is related to the specification of FNM_PATHNAME. A period is always leading if it is the first character in .IR string . Additionally, if FNM_PATHNAME is set, a period is leading if it immediately follows a slash. .TP 15 FNM_LEADING_DIR Ignore /* rest after successful .IR pattern matching. .TP 15 FNM_CASEFOLD Ignore case distinctions in both the .IR pattern and the .IR string . .SH RETURN VALUES The .B fnmatch function returns zero if .IR string matches the pattern specified by .IR pattern , otherwise, it returns the value FNM_NOMATCH. .SH SEE ALSO .BR sh (1), .BR regex (3), .SH HISTORY The .B fnmatch function first appeared in 4.4BSD. .SH BUGS The pattern * matches the empty string, even if FNM_PATHNAME is specified.