📄 fnmatch.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>fnmatch</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_005_149"> </a>NAME</h4><blockquote>fnmatch - match a filename or a pathname</blockquote><h4><a name = "tag_000_005_150"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="fnmatch.h.html">fnmatch.h</a>>int fnmatch(const char *<i>pattern</i>, const char *<i>string</i>, int <i>flags</i>);</code></pre></blockquote><h4><a name = "tag_000_005_151"> </a>DESCRIPTION</h4><blockquote>The<i>fnmatch()</i>function matches patterns as described in the <b>XCU</b> specification, <b>Section 2.13.1</b>, <b>Patterns Matching a Single Character</b>, and <b>Section 2.13.2</b>, <b>Patterns Matching Multiple Characters</b>.It checks the string specified by the<i>string</i>argument to see if it matches the pattern specified by the<i>pattern</i>argument.<p>The<i>flags</i>argument modifies the interpretation of<i>pattern</i>and<i>string</i>.It is the bitwise inclusive OR of zero or more of the flags defined in theheader<i><a href="fnmatch.h.html"><fnmatch.h></a></i>.If the FNM_PATHNAME flag is set in<i>flags</i>,then a slash character in<i>string</i>will be explicitly matched by a slash in<i>pattern</i>;it will not be matched by either the asterisk or question-mark specialcharacters, nor by a bracket expression.If the FNM_PATHNAME flag is not set,the slash character is treated as anordinary character.<p>If FNM_NOESCAPE is not set in<i>flags</i>,a backslash character (\) in<i>pattern</i>followed by any other character will match that second character in<i>string</i>.In particular, \\ will match a backslash in<i>string</i>.If FNM_NOESCAPE is set, a backslash character willbe treated as an ordinary character.<p>If FNM_PERIOD is set in<i>flags</i>,then a leading period in<i>string</i>will match a period in<i>pattern</i>;as described by rule 2 in the <b>XCU</b> specification, <b>Section 2.13.3</b>, <b>Patterns Used for Filename Expansion</b>where the location of "leading" is indicated by the value of FNM_PATHNAME:<ul><p><li>If FNM_PATHNAME is set, a period is"leading" if it is the first character in<i>string</i>or if it immediately follows a slash.<p><li>If FNM_PATHNAME is not set, a period is"leading" only if it is the first character of<i>string</i>.<p></ul><p>If FNM_PERIOD is not set, then no special restrictions areplaced on matching a period.</blockquote><h4><a name = "tag_000_005_152"> </a>RETURN VALUE</h4><blockquote>If<i>string</i>matches the pattern specified by<i>pattern</i>,then<i>fnmatch()</i>returns 0.If there is no match,<i>fnmatch()</i>returns FNM_NOMATCH, which is defined in the header<i><a href="fnmatch.h.html"><fnmatch.h></a></i>.If an error occurs,<i>fnmatch()</i>returns another non-zero value.</blockquote><h4><a name = "tag_000_005_153"> </a>ERRORS</h4><blockquote>No errors are defined.<br></blockquote><h4><a name = "tag_000_005_154"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_155"> </a>APPLICATION USAGE</h4><blockquote>The<i>fnmatch()</i>function has two major uses.It could be used by an application or utility that needs to read adirectory and apply a pattern against each entry.The<i><a href="../xcu/find.html">find</a></i>utility is an example of this.It can also be used by the<i><a href="../xcu/pax.html">pax</a></i>utility to process its<i>pattern</i>operands, or by applications that need to match strings in asimilar manner.<p>The name<i>fnmatch()</i>is intended to imply<i>filename</i>match, rather than<i>pathname</i>match.The default action of this function is to match filenames, rather thanpathnames, since it gives no special significance to the slashcharacter.With the FNM_PATHNAME flag,<i>fnmatch()</i>does match pathnames, but without tilde expansion, parameter expansion, orspecial treatment for period at the beginning of a filename.</blockquote><h4><a name = "tag_000_005_156"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_157"> </a>SEE ALSO</h4><blockquote><i><a href="glob.html">glob()</a></i>,<i><a href="wordexp.html">wordexp()</a></i>,<i><a href="fnmatch.h.html"><fnmatch.h></a></i>,the <b>XCU</b> specification.</blockquote><h4>DERIVATION</h4><blockquote>Derived from the ISO POSIX-2 standard.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -