{"id":4724,"date":"2022-12-20T18:36:49","date_gmt":"2022-12-20T21:36:49","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/fnmatch-man3p\/"},"modified":"2022-12-20T18:36:49","modified_gmt":"2022-12-20T21:36:49","slug":"fnmatch-man3p","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/fnmatch-man3p\/","title":{"rendered":"FNMATCH (man3p)"},"content":{"rendered":"<h1 align=\"center\">FNMATCH<\/h1>\n<p> <a href=\"#PROLOG\">PROLOG<\/a><br \/> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#ERRORS\">ERRORS<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#APPLICATION USAGE\">APPLICATION USAGE<\/a><br \/> <a href=\"#RATIONALE\">RATIONALE<\/a><br \/> <a href=\"#FUTURE DIRECTIONS\">FUTURE DIRECTIONS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>PROLOG <a name=\"PROLOG\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This manual page is part of the POSIX Programmer\u2019s Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">fnmatch \u2014 match a filename string or a pathname<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">#include <fnmatch.h><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int fnmatch(const char *<i>pattern<\/i>, const char *<i>string<\/i>, int <i>flags<\/i>);<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>fnmatch<\/i>() function shall match patterns as described in the Shell and Utilities volume of POSIX.1-2017, <i>Section 2.13.1<\/i>, <i>Patterns Matching a Single Character<\/i> and <i>Section 2.13.2<\/i>, <i>Patterns Matching Multiple Characters<\/i>. 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>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>flags<\/i> argument shall modify 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 <i><fnmatch.h><\/i>. If the FNM_PATHNAME flag is set in <i>flags<\/i>, then a <slash> character (<b>\u2019\/\u2019<\/b>) in <i>string<\/i> shall be explicitly matched by a <slash> in <i>pattern<\/i>; it shall not be matched by either the <asterisk> or <question-mark> special characters, nor by a bracket expression. If the FNM_PATHNAME flag is not set, the <slash> character shall be treated as an ordinary character.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If FNM_NOESCAPE is not set in <i>flags<\/i>, a <backslash> character in <i>pattern<\/i> followed by any other character shall match that second character in <i>string<\/i>. In particular, <b>&#8220;\\&#8221;<\/b> shall match a <backslash> in <i>string<\/i>. If <i>pattern<\/i> ends with an unescaped <backslash>, <i>fnmatch<\/i>() shall return a non-zero value (indicating either no match or an error). If FNM_NOESCAPE is set, a <backslash> character shall be treated as an ordinary character.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If FNM_PERIOD is set in <i>flags<\/i>, then a leading <period> (<b>\u2019.\u2019<\/b>) in <i>string<\/i> shall match a <period> in <i>pattern<\/i>; as described by rule 2 in the Shell and Utilities volume of POSIX.1-2017, <i>Section 2.13.3<\/i>, <i>Patterns Used for Filename Expansion<\/i> where the location of \u2018\u2018leading\u2019\u2019 is indicated by the value of FNM_PATHNAME:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>If FNM_PATHNAME is set, a <period> is \u2018\u2018leading\u2019\u2019 if it is the first character in <i>string<\/i> or if it immediately follows a <slash>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>If FNM_PATHNAME is not set, a <period> is \u2018\u2018leading\u2019\u2019 only if it is the first character of <i>string<\/i>.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">If FNM_PERIOD is not set, then no special restrictions are placed on matching a period.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">If <i>string<\/i> matches the pattern specified by <i>pattern<\/i>, then <i>fnmatch<\/i>() shall return 0. If there is no match, <i>fnmatch<\/i>() shall return FNM_NOMATCH, which is defined in <i><fnmatch.h><\/i>. If an error occurs, <i>fnmatch<\/i>() shall return another non-zero value.<\/p>\n<h2>ERRORS <a name=\"ERRORS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">No errors are defined.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>The following sections are informative.<\/i><\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>APPLICATION USAGE <a name=\"APPLICATION USAGE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>fnmatch<\/i>() function has two major uses. It could be used by an application or utility that needs to read a directory and apply a pattern against each entry. The <i>find<\/i> utility is an example of this. It can also be used by the <i>pax<\/i> utility to process its <i>pattern<\/i> operands, or by applications that need to match strings in a similar manner.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">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 filename strings, rather than pathnames, since it gives no special significance to the <slash> character. With the FNM_PATHNAME flag, <i>fnmatch<\/i>() does match pathnames, but without tilde expansion, parameter expansion, or special treatment for a <period> at the beginning of a filename.<\/p>\n<h2>RATIONALE <a name=\"RATIONALE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This function replaced the REG_FILENAME flag of <i>regcomp<\/i>() in early proposals of this volume of POSIX.1-2017. It provides virtually the same functionality as the <i>regcomp<\/i>() and <i>regexec<\/i>() functions using the REG_FILENAME and REG_FSLASH flags (the REG_FSLASH flag was proposed for <i>regcomp<\/i>(), and would have had the opposite effect from FNM_PATHNAME), but with a simpler function and less system overhead.<\/p>\n<h2>FUTURE DIRECTIONS <a name=\"FUTURE DIRECTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>glob<\/i>(), <i>Section 2.6<\/i>, <i>Word Expansions<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The Base Definitions volume of POSIX.1-2017, <b><fnmatch.h><\/b><\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology &#8212; Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version 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 .<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https:\/\/www.kernel.org\/doc\/man-pages\/reporting_bugs.html .<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  fnmatch \u2014 match a filename string or a pathname <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3779,1],"tags":[1645,1594],"class_list":["post-4724","post","type-post","status-publish","format-standard","hentry","category-3pm-perl-llamadas-de-bibliotecas","category-sin-categoria","tag-fnmatch","tag-man3p"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=4724"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4724\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=4724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=4724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=4724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}