FNMATCH(3am)

πŸ’– FNMATCH(3am) πŸ’–

okay bestie, so this is fnmatch from the GNU Awk Extension Modules β€” it's the gawk manual page, and I'm about to make it make sense for you. no cap.


✨ NAME ✨

fnmatch β€” compare a string against a filename wildcard πŸ¦‹


✨ SYNOPSIS ✨

@load "fnmatch"

result = fnmatch(pattern, string, flags)

✨ DESCRIPTION ✨

so the fnmatch extension is basically a little bridge β€” it gives AWK an interface to the fnmatch(3) routine. and when you load it, you get three things:

  • a single function called fnmatch()
  • one predefined variable, FNM_NOMATCH
  • an array of flag values, named FNM

here's how the arguments go, bestie:

  • the first argument is the filename wildcard you wanna match against
  • the second is the filename string itself
  • the third is either zero, or the bitwise OR of one or more of the flags living in the FNM array

and the return value? okay so:

  • 0 means success, slay πŸ’…
  • FNM_NOMATCH means the string did not match the pattern
  • any other non-zero value means an error happened 😭

the flags, one by one πŸŽ€

  • FNM["CASEFOLD"] β€” corresponds to the FNM_CASEFOLD flag as defined in fnmatch(3).
  • FNM["FILE_NAME"] β€” corresponds to the FNM_FILE_NAME flag as defined in fnmatch(3).
  • FNM["LEADING_DIR"] β€” corresponds to the FNM_LEADING_DIR flag as defined in fnmatch(3).
  • FNM["NOESCAPE"] β€” corresponds to the FNM_NOESCAPE flag as defined in fnmatch(3).
  • FNM["PATHNAME"] β€” corresponds to the FNM_PATHNAME flag as defined in fnmatch(3).
  • FNM["PERIOD"] β€” corresponds to the FNM_PERIOD flag as defined in fnmatch(3).

✨ NOTES ✨

lowkey important: nothing stops your AWK code from changing the predefined variable FNM_NOMATCH... but doing that may cause strange results. so like, don't? πŸ™ˆ

✨ EXAMPLE ✨

here's the vibe, literally copy-paste coded:

@load "fnmatch"
...
flags = or(FNM["PERIOD"], FNM["NOESCAPE"])
if (fnmatch("*.a", "foo.c", flags) == FNM_NOMATCH)
     print "no match"

✨ SEE ALSO ✨

  • GAWK: Effective AWK Programming, plus the man pages for the other extensions shipped with gawk. πŸ‘‘
  • fnmatch(3).

✨ AUTHOR ✨

Arnold Robbins, arnold@skeeve.com. 🫢


✨ COPYING PERMISSIONS ✨

Copyright © 2012, 2013, 2018, 2026, Free Software Foundation, Inc. ⭐

Permission is granted to make and distribute verbatim copies of this manual page provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation.


and that's the whole page, bestie 🧚 this was brought to you by the Free Software Foundation, dated Feb 25 2026, and it's page FNMATCH(3am) β€” periodt. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from