O'Reilly logo

Advanced UNIX Programming by Warren W. Gay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

String Pattern Functions

To simplify program development of shells and other related functions that require this pattern matching capability, the function fnmatch(3) was developed. The function synopsis for it is as follows:

#include <fnmatch.h>

int fnmatch(const char *pattern, const char *string, int flags);

The argument pattern is the input pattern string, which is compared with the input argument string. The argument pattern contains the meta-characters, if any. The argument string is the string that you want to test for a match. The argument flags enables and disables certain features of the fnmatch(3) function.

The return value from fnmatch(3) is zero if a match is made. Otherwise, the value FNM_NOMATCH is returned instead.

Note

When the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required