manpagez: man pages & more
info gawk
Home | html | info | man

gawk: Extension Sample Fnmatch

 16.7.2 Interface to 'fnmatch()'
 This extension provides an interface to the C library 'fnmatch()'
 function.  The usage is:
 '@load "fnmatch"'
      This is how you load the extension.
 'result = fnmatch(pattern, string, flags)'
      The return value is zero on success, 'FNM_NOMATCH' if the string
      did not match the pattern, or a different nonzero value if an error
    In addition to the 'fnmatch()' function, the 'fnmatch' extension adds
 one constant ('FNM_NOMATCH'), and an array of flag values named 'FNM'.
    The arguments to 'fnmatch()' are:
      The file name wildcard to match
      The file name string
      Either zero, or the bitwise OR of one or more of the flags in the
      'FNM' array
    The flags are as follows:
 Array element      Corresponding flag defined by 'fnmatch()'
    Here is an example:
      @load "fnmatch"
      flags = or(FNM["PERIOD"], FNM["NOESCAPE"])
      if (fnmatch("*.a", "foo.c", flags) == FNM_NOMATCH)
          print "no match"
© 2000-2018
Individual documents may contain additional copyright information.