fnmatchのヘルプ・マニュアル
日本語 英語
fnmatch --help
man fnmatch
FNMATCH(3) Linux Programmer’s Manual FNMATCH(3)
名前
fnmatch - ファイル名またはパス名へのマッチを行う
書式
#include
int fnmatch(const char *pattern, const char *string, int flags);
説明
fnmatch() 関数は strings 引き数が pattern 引き数にマッチするかをチェッ
クする。 pattern にはシェルのワイルドカードパターンを与える。
flags 引き数により動作を変更できる。 flags は以下のフラグのビット 毎 の
OR で指定する。
FNM_NOESCAPE
こ のフラグがセットされていると、バックスラッシュ (\) をエスケー
プ文字ではなく通常の文字として扱う。
FNM_PATHNAME
このフラグがセットされていると、 string 中のスラッシュ (/) を
pattern にあるスラッシュそのものにだけマッチさせ、アスタリスク
(*) や疑問符 (?) のメタキャラクタや、スラッシュを含むブラケッ ト
表現 ([]) にはマッチさせない。
FNM_PERIOD
こ のフラグがセットされていると、 string の先頭ピリオド (leading
period) は pattern 中のピリオドそのものにしかマッチしない。先 頭
ピリオドとは、 string の最初の文字位置にあるピリオドのことである
。ただし FNM_PATHNAME フラグが同時にセットされている場合には、ス
ラッシュの直後に続くピリオドも先頭ピリオドとみなされる。
FNM_FILE_NAME
これは FNM_PATHNAME に対する GNU での同義語である.
FNM_LEADING_DIR
こ のフラグは GNU での拡張である。これがセットされている場合には
、パターンが string の最初の部分 (にスラッシュを付けたもの) にマ
ッ チ す れ ば、マッチしたものとみなされる。このフラグは主として
glibc で内部的に使用し、そのためのみ実装されている。
FNM_CASEFOLD
このフラグは GNU での拡張である。これがセットされている場合に は
、パターンのマッチに大文字小文字が区別されない。
返り値
string が pattern にマッチすれば 0 を返す。マッチしなかった場合には
FNM_NOMATCH を返す。エラーの場合にはそれ以外の非ゼロ値を返す。
準拠
POSIX.2. FNM_FILE_NAME, FNM_LEADING_DIR, FNM_CASEFOLD フラグは GNU の
拡張である。
関連項目
sh(1), glob(3), scandir(3), wordexp(3), glob(7)
GNU 2000-10-15 FNMATCH(3)
FNMATCH(3) Linux Programmer’s Manual FNMATCH(3)
NAME
fnmatch - match filename or pathname
SYNOPSIS
#include
int fnmatch(const char *pattern, const char *string, int flags);
DESCRIPTION
The fnmatch() function checks whether the string argument matches the
pattern argument, which is a shell wildcard pattern.
The flags argument modifies the behavior; it is the bitwise OR of zero
or more of the following flags:
FNM_NOESCAPE
If this flag is set, treat backslash as an ordinary character,
instead of an escape character.
FNM_PATHNAME
If this flag is set, match a slash in string only with a slash
in pattern and not by an asterisk (*) or a question mark (?)
metacharacter, nor by a bracket expression ([]) containing a
slash.
FNM_PERIOD
If this flag is set, a leading period in string has to be
matched exactly by a period in pattern. A period is considered
to be leading if it is the first character in string, or if both
FNM_PATHNAME is set and the period immediately follows a slash.
FNM_FILE_NAME
This is a GNU synonym for FNM_PATHNAME.
FNM_LEADING_DIR
If this flag (a GNU extension) is set, the pattern is considered
to be matched if it matches an initial segment of string which
is followed by a slash. This flag is mainly for the internal
use of glibc and is only implemented in certain cases.
FNM_CASEFOLD
If this flag (a GNU extension) is set, the pattern is matched
case-insensitively.
RETURN VALUE
Zero if string matches pattern, FNM_NOMATCH if there is no match or
another non-zero value if there is an error.
CONFORMING TO
POSIX.2. The FNM_FILE_NAME, FNM_LEADING_DIR, and FNM_CASEFOLD flags
are GNU extensions.
SEE ALSO
sh(1), glob(3), scandir(3), wordexp(3), glob(7)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2000-10-15 FNMATCH(3)