Print this page
1209 fnmatch(3C) should mention FNM_IGNORECASE
Reviewed by: Marcel Telka <marcel@telka.sk>
   1 '\" te
   2 .\"  Copyright (c) 1992, X/Open Company Limited All Rights Reserved  Portions Copyright (c) 2002, Sun Microsystems, Inc.  All Rights Reserved
   3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
   4 .\" http://www.opengroup.org/bookstore/.
   5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
   6 .\"  This notice shall appear on any product containing this material.
   7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  10 .TH FNMATCH 3C "Jul 24, 2002"
  11 .SH NAME
  12 fnmatch \- match filename or path name
  13 .SH SYNOPSIS
  14 .LP
  15 .nf
  16 #include <fnmatch.h>
  17 
  18 \fBint\fR \fBfnmatch\fR(\fBconst char *\fR\fIpattern\fR, \fBconst char *\fR\fIstring\fR, \fBint\fR \fIflags\fR);
  19 .fi
  20 
  21 .SH DESCRIPTION
  22 .sp
  23 .LP
  24 The \fBfnmatch()\fR function matches patterns as described on the
  25 \fBfnmatch\fR(5) manual page.  It checks the \fIstring\fR argument to see if it
  26 matches the \fIpattern\fR argument.
  27 .sp
  28 .LP
  29 The \fIflags\fR argument modifies the interpretation of \fIpattern\fR and
  30 \fIstring\fR. It is the bitwise inclusive \fBOR\fR of zero or more of the
  31 following flags defined in the header <\fBfnmatch.h\fR>.
  32 .sp
  33 .ne 2
  34 .na
  35 \fB\fBFNM_PATHNAME\fR  \fR
  36 .ad
  37 .RS 18n
  38 If set, a slash (\fB/\fR) character in \fIstring\fR will be explicitly matched
  39 by a slash in \fIpattern\fR; it will not be matched by either the asterisk
  40 (\fB*\fR) or question-mark (\fB?\fR) special characters, nor by a bracket
  41 (\fB[\|]\fR) expression.
  42 .sp
  43 If not set, the slash character is treated as an ordinary character.
  44 .RE
  45 
  46 .sp
  47 .ne 2
  48 .na















  49 \fB\fBFNM_NOESCAPE\fR\fR
  50 .ad
  51 .RS 18n
  52 If not set, a backslash character (\fB\e\fR) in \fIpattern\fR followed by any
  53 other character will match that second character in \fIstring\fR. In
  54 particular, "\fB\e\e\fR" will match a backslash in \fIstring\fR.
  55 .sp
  56 If set, a backslash character will be treated as an ordinary character.
  57 .RE
  58 
  59 .sp
  60 .ne 2
  61 .na
  62 \fB\fBFNM_PERIOD\fR\fR
  63 .ad
  64 .RS 18n
  65 If set, a leading period in \fIstring\fR will match a period in \fIpattern\fR;
  66 where the location of "leading" is indicated by the value of
  67 \fBFNM_PATHNAME\fR:
  68 .RS +4
  69 .TP
  70 .ie t \(bu
  71 .el o
  72 If \fBFNM_PATHNAME\fR is set, a period is "leading" if it is the first
  73 character in \fIstring\fR or if it immediately follows a slash.
  74 .RE
  75 .RS +4
  76 .TP
  77 .ie t \(bu
  78 .el o
  79 If \fBFNM_PATHNAME\fR is not set, a period is "leading" only if it is the first
  80 character of \fIstring\fR.
  81 .RE
  82 .RE
  83 
  84 .sp
  85 .LP
  86 If not set, no special restrictions are placed on matching a period.
  87 .SH RETURN VALUES
  88 .sp
  89 .LP
  90 If \fIstring\fR matches the pattern specified by \fIpattern\fR, then
  91 \fBfnmatch()\fR returns \fB0\fR. If there is no match, \fBfnmatch()\fR returns
  92 \fBFNM_NOMATCH\fR, which is defined in the header <\fBfnmatch.h\fR>. If an
  93 error occurs, \fBfnmatch()\fR returns another non-zero value.
  94 .SH USAGE
  95 .sp
  96 .LP
  97 The \fBfnmatch()\fR function has two major uses. It could be used by an
  98 application or utility that needs to read a directory and apply a pattern
  99 against each entry. The \fBfind\fR(1) utility is an example of this. It can
 100 also be used by the \fBpax\fR(1) utility to process its \fIpattern\fR operands,
 101 or by applications that need to match strings in a similar manner.
 102 .sp
 103 .LP
 104 The name \fBfnmatch()\fR is intended to imply \fIfilename\fR match, rather than
 105 \fIpathname\fR match. The default action of this function is to match


   1 '\" te
   2 .\"  Copyright (c) 1992, X/Open Company Limited All Rights Reserved  Portions Copyright (c) 2002, Sun Microsystems, Inc.  All Rights Reserved
   3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
   4 .\" http://www.opengroup.org/bookstore/.
   5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
   6 .\"  This notice shall appear on any product containing this material.
   7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  10 .TH FNMATCH 3C "Jun 6, 2015"
  11 .SH NAME
  12 fnmatch \- match filename or path name
  13 .SH SYNOPSIS
  14 .LP
  15 .nf
  16 #include <fnmatch.h>
  17 
  18 \fBint\fR \fBfnmatch\fR(\fBconst char *\fR\fIpattern\fR, \fBconst char *\fR\fIstring\fR, \fBint\fR \fIflags\fR);
  19 .fi
  20 
  21 .SH DESCRIPTION
  22 .sp
  23 .LP
  24 The \fBfnmatch()\fR function matches patterns as described on the
  25 \fBfnmatch\fR(5) manual page.  It checks the \fIstring\fR argument to see if it
  26 matches the \fIpattern\fR argument.
  27 .sp
  28 .LP
  29 The \fIflags\fR argument modifies the interpretation of \fIpattern\fR and
  30 \fIstring\fR. It is the bitwise inclusive \fBOR\fR of zero or more of the
  31 following flags defined in the header <\fBfnmatch.h\fR>.
  32 .sp
  33 .ne 2
  34 .na
  35 \fB\fBFNM_PATHNAME\fR  \fR
  36 .ad
  37 .RS 18n
  38 If set, a slash (\fB/\fR) character in \fIstring\fR will be explicitly matched
  39 by a slash in \fIpattern\fR; it will not be matched by either the asterisk
  40 (\fB*\fR) or question-mark (\fB?\fR) special characters, nor by a bracket
  41 (\fB[\|]\fR) expression.
  42 .sp
  43 If not set, the slash character is treated as an ordinary character.
  44 .RE
  45 
  46 .sp
  47 .ne 2
  48 .na
  49 \fB\fBFNM_IGNORECASE\fR\fR
  50 .ad
  51 .RS 18n
  52 If set, the \fIstring\fR will be transliterated to lower case before doing the
  53 actual match. This transliteration is done using \fBtowlower_l\fR(3C), using
  54 the locale of the current thread. If no locale is set, then the global locale
  55 is used instead.
  56 .sp
  57 If not set, the match will use \fIstring\fR with no changes, making the match
  58 case-sensitive.
  59 .RE
  60 
  61 .sp
  62 .ne 2
  63 .na
  64 \fB\fBFNM_NOESCAPE\fR\fR
  65 .ad
  66 .RS 18n
  67 If not set, a backslash character (\fB\e\fR) in \fIpattern\fR followed by any
  68 other character will match that second character in \fIstring\fR. In
  69 particular, "\fB\e\e\fR" will match a backslash in \fIstring\fR.
  70 .sp
  71 If set, a backslash character will be treated as an ordinary character.
  72 .RE
  73 
  74 .sp
  75 .ne 2
  76 .na
  77 \fB\fBFNM_PERIOD\fR\fR
  78 .ad
  79 .RS 18n
  80 If set, a leading period in \fIstring\fR will match a period in \fIpattern\fR;
  81 where the location of "leading" is indicated by the value of
  82 \fBFNM_PATHNAME\fR:
  83 .RS +4
  84 .TP
  85 .ie t \(bu
  86 .el o
  87 If \fBFNM_PATHNAME\fR is set, a period is "leading" if it is the first
  88 character in \fIstring\fR or if it immediately follows a slash.
  89 .RE
  90 .RS +4
  91 .TP
  92 .ie t \(bu
  93 .el o
  94 If \fBFNM_PATHNAME\fR is not set, a period is "leading" only if it is the first
  95 character of \fIstring\fR.
  96 .RE
  97 .RE
  98 
  99 .sp
 100 .RS 18n
 101 If not set, no special restrictions are placed on matching a period.
 102 .SH RETURN VALUES
 103 .sp
 104 .LP
 105 If \fIstring\fR matches the pattern specified by \fIpattern\fR, then
 106 \fBfnmatch()\fR returns \fB0\fR. If there is no match, \fBfnmatch()\fR returns
 107 \fBFNM_NOMATCH\fR, which is defined in the header <\fBfnmatch.h\fR>. If an
 108 error occurs, \fBfnmatch()\fR returns another non-zero value.
 109 .SH USAGE
 110 .sp
 111 .LP
 112 The \fBfnmatch()\fR function has two major uses. It could be used by an
 113 application or utility that needs to read a directory and apply a pattern
 114 against each entry. The \fBfind\fR(1) utility is an example of this. It can
 115 also be used by the \fBpax\fR(1) utility to process its \fIpattern\fR operands,
 116 or by applications that need to match strings in a similar manner.
 117 .sp
 118 .LP
 119 The name \fBfnmatch()\fR is intended to imply \fIfilename\fR match, rather than
 120 \fIpathname\fR match. The default action of this function is to match