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
FNMarray
and the return value? okay so:
0means success, slay πFNM_NOMATCHmeans 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 theFNM_CASEFOLDflag as defined infnmatch(3).FNM["FILE_NAME"]β corresponds to theFNM_FILE_NAMEflag as defined infnmatch(3).FNM["LEADING_DIR"]β corresponds to theFNM_LEADING_DIRflag as defined infnmatch(3).FNM["NOESCAPE"]β corresponds to theFNM_NOESCAPEflag as defined infnmatch(3).FNM["PATHNAME"]β corresponds to theFNM_PATHNAMEflag as defined infnmatch(3).FNM["PERIOD"]β corresponds to theFNM_PERIODflag as defined infnmatch(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
- arch rolling: gawk 5.4.1-1 Β· GPL-3.0-or-later
- nixos 26.05: gawk-interactive 5.4.1
- nixpkgs unstable: gawk 5.4.1
- nixpkgs unstable: gawk-interactive 5.4.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms