Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Glob (programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Patterns used in computer programming}} {{lowercase}} {{Use dmy dates|date=July 2019|cs1-dates=y}} [[File:Unix Glob Reference.png|thumb|A screenshot of the original 1971 Unix reference page for <code>glob</code> β the owner is <code>dmr</code>, short for [[Dennis Ritchie]].]] '''glob()''' ({{IPAc-en|g|l|Ι|b}}) is a [[C standard library|libc]] function for '''''globbing''''', which is the archetypal use of pattern matching against the [[File_system#DENTRY|names in a filesystem directory]] such that a name pattern is expanded into a list of names matching that pattern. Although ''globbing'' may now refer to glob()-style pattern matching of any string, not just expansion into a list of filesystem names, the original meaning of the term is still widespread. The <code>glob()</code> function and the underlying <code>gmatch()</code><!-- NOT fnmatch(), which first appeared in 4.4BSD --> function originated at [[Bell Labs]] in the early 1970s alongside the original [[Research Unix|AT&T UNIX]] itself and had a formative influence on the syntax of UNIX command line utilities and therefore also on the present-day reimplementations thereof. In their original form, <code>glob()</code> and <code>gmatch()</code> derived from code used in [[Bell Labs]] in-house utilities that developed alongside the original Unix in the early 1970s. Among those utilities were also two command line tools called <code>glob</code> and <code>[[find (Unix)|find]]</code>; each could be used to pass a list of matching filenames to other command line tools, and they shared the backend code subsequently formalized as <code>glob()</code> and <code>gmatch()</code>. Shell-statement-level globbing by default became commonplace following the [[Shell builtin|"builtin"-integration]] of globbing-functionality into the [[Version 7 Unix|7th edition]] of the [[Unix shell]] in 1978. The Unix shell's -f option to disable globbing — i.e. revert to literal "file" mode — appeared in the same version. The glob ''pattern quantifiers'' now standardized by [[POSIX|POSIX.2]] (IEEE Std 1003.2) fall into two groups, and can be applied to any character sequence ("string"), not just to directory entries. * "Metacharacters" (also called "Wildcards"): ** <code>?</code> (not in brackets) matches any character exactly once. ** <code>*</code> (not in brackets) matches a string of zero or more characters. * "Ranges/sets": ** <code><nowiki>[...]</nowiki></code>, where the first character within the brackets is not '!', matches any single character among the characters specified in the brackets. If the first character within brackets is '!', then the <code><nowiki>[!...]</nowiki></code> matches any single character that is ''not'' among the characters specified in the brackets. :: The characters in the brackets may be a list (<code><nowiki>[abc]</nowiki></code>) or a range (<code><nowiki>[a-c]</nowiki></code>) or denote a character class (like <code><nowiki>[[:space:]]</nowiki></code> where the inner brackets are part of the classname). POSIX does not mandate multi-range (<code><nowiki>[a-c0-3]</nowiki></code>) support, which derive originally from [[regular expressions]]. As reimplementations of [[Bell Labs]]' UNIX proliferated, so did reimplementations of its Bell Labs' libc and shell, and with them <code>glob()</code> and ''globbing''. Today, <code>glob()</code> and ''globbing'' are standardized by the [[POSIX|POSIX.2]] specification and are integral part of every Unix-like libc ecosystem and shell, including AT&T Bourne shell-compatible [[Korn shell|Korn shell (ksh)]], [[Z shell|Z shell (zsh)]], [[Almquist shell|Almquist shell (ash)]] and its derivatives and reimplementations such as [[busybox]], [[toybox]], [[Bash (Unix shell)|GNU bash]], [[Debian|Debian dash]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)