Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

file::fnmatch(3pm) [debian man page]

FnMatch(3pm)						User Contributed Perl Documentation					      FnMatch(3pm)

NAME
File::FnMatch - simple filename and pathname matching SYNOPSIS
use File::FnMatch qw(:fnmatch); # import everything # shell-style: match "/a/bc", but not "/a/.bc" nor "/a/b/c" fnmatch("/a/*", $fn, FNM_PATHNAME|FNM_PERIOD); # find our A- executables only grep { fnmatch("A-*.exe", $_) } readdir SOMEDIR; DESCRIPTION
File::FnMatch::fnmatch() provides simple, shell-like pattern matching. Though considerably less powerful than regular expressions, shell patterns are nonetheless useful and familiar to a large audience of end- users. Functions fnmatch ( PATTERN, STRING [, FLAGS] ) Returns true if PATTERN matches STRING, undef otherwise. FLAGS may be the bitwise OR'ing of any supported FNM_* constants (see below). Constants FNM_NOESCAPE Do not treat a backslash ('') in PATTERN specially. Otherwise, a backslash escapes the following character. FNM_PATHNAME Prohibit wildcards from matching a slash ('/'). FNM_PERIOD Prohibit wildcards from matching a period ('.') at the start of a string and, if FNM_PATHNAME is also given, immediately after a slash. Other possibilities include at least FNM_CASEFOLD (compare "qr//i"), FNM_LEADING_DIR to restrict matching to everything before the first '/', FNM_FILE_NAME as a synonym for FNM_PATHNAME, and the rather more exotic FNM_EXTMATCH. Consult your system documentation for details. EXPORT None by default. The export tag ":fnmatch" exports the fnmatch function and all available FNM_* constants. PATTERN SYNTAX
Wildcards are the question mark ('?') to match any single character and the asterisk ('*') to match zero or more characters. FNM_PATHNAME and FNM_PERIOD restrict the scope of the wildcards, notably supporting the UNIX convention of concealing "dotfiles": Bracket expressions, enclosed by '[' and ']', match any of a set of characters specified explicitly ("[abcdef]"), as a range ("[a-f0-9]"), or as the combination these ("[a-f0-9XYZ]"). Additionally, many implementations support named character classes such as "[[:xdigit:]]". Character sets may be negated with an initial '!' ("[![:space:]]"). Locale influences the meaning of fnmatch() patterns. CAVEATS
Most UNIX-like systems provide an fnmatch implementation. This module will not work on platforms lacking an implementation, most notably Win32. SEE ALSO
File::Glob, POSIX::setlocale, fnmatch(3) AUTHOR
Michael J. Pomraning Please report bugs to <mjp-perl AT pilcrow.madison.wi.us> COPYRIGHT AND LICENSE
Copyright 2005 by Michael J. Pomraning This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2005-03-30 FnMatch(3pm)

Check Out this Related Man Page

fnmatch(3C)						   Standard C Library Functions 					       fnmatch(3C)

NAME
fnmatch - match filename or path name SYNOPSIS
#include <fnmatch.h> int fnmatch(const char *pattern, const char *string, int flags); DESCRIPTION
The fnmatch() function matches patterns as described on the fnmatch(5) manual page. It checks the string argument to see if it matches the pattern argument. The flags argument modifies the interpretation of pattern and string. It is the bitwise inclusive OR of zero or more of the following flags defined in the header <fnmatch.h>. FNM_PATHNAME If set, a slash (/) character in string will be explicitly matched by a slash in pattern; it will not be matched by either the asterisk (*) or question-mark (?) special characters, nor by a bracket ([]) expression. If not set, the slash character is treated as an ordinary character. FNM_NOESCAPE If not set, a backslash character () in pattern followed by any other character will match that second character in string. In particular, "\" will match a backslash in string. If set, a backslash character will be treated as an ordinary character. FNM_PERIOD If set, a leading period in string will match a period in pattern; where the location of "leading" is indicated by the value of FNM_PATHNAME: o If FNM_PATHNAME is set, a period is "leading" if it is the first character in string or if it immediately fol- lows a slash. o If FNM_PATHNAME is not set, a period is "leading" only if it is the first character of string. If not set, no special restrictions are placed on matching a period. RETURN VALUES
If string matches the pattern specified by pattern, then fnmatch() returns 0. If there is no match, fnmatch() returns FNM_NOMATCH, which is defined in the header <fnmatch.h>. If an error occurs, fnmatch() returns another non-zero value. USAGE
The fnmatch() 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 find(1) utility is an example of this. It can also be used by the pax(1) utility to process its pattern operands, or by applications that need to match strings in a similar manner. The name fnmatch() is intended to imply filename match, rather than pathname match. The default action of this function is to match file- names, rather than path names, since it gives no special significance to the slash character. With the FNM_PATHNAME flag, fnmatch() does match path names, but without tilde expansion, parameter expansion, or special treatment for period at the beginning of a filename. The fnmatch() function can be used safely in multithreaded applications, as long as setlocale(3C) is not being called to change the locale. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe with exceptions | +-----------------------------+-----------------------------+ SEE ALSO
find(1), pax(1), glob(3C), setlocale(3C), wordexp(3C), attributes(5), fnmatch(5), standards(5) SunOS 5.10 24 Jul 2002 fnmatch(3C)
Man Page