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!
===Unix-like{{anchor|Unix}}=== On [[Unix-like]] systems {{code|*}}, {{code|?}} is defined as above while {{code|[β¦]}} has two additional meanings:<ref name="posixglob"/><ref name="linuxglob7"/> {| class="wikitable" |- ! Wildcard ! Description ! Example ! Matches ! Does not match |- | {{code|[!abc]}} | matches one character that is not given in the bracket | {{code|[!C]at}} | {{code|Bat}}, {{code|bat}}, or {{code|cat}} | {{code|Cat}} |- | {{code|[!a-z]}} | matches one character that is not from the range given in the bracket | {{code|Letter[!3-5]}} | {{code|Letter1}}, {{code|Letter2}}, {{code|Letter6}} up to {{code|Letter9}} and {{code|Letterx}} etc. | {{code|Letter3}}, {{code|Letter4}}, {{code|Letter5}} or {{code|Letterxx}} |} The ranges are also allowed to include pre-defined character classes, equivalence classes for accented characters, and collation symbols for hard-to-type characters. They are defined to match up with the brackets in POSIX regular expressions.<ref name="posixglob"/><ref name="linuxglob7"/> Unix globbing is handled by the [[Shell (computing)|shell]] per POSIX tradition. Globbing is provided on filenames at the [[command line interface|command line]] and in [[shell script]]s.<ref name="ABSGlob"/> The POSIX-mandated <code>case</code> statement in shells provides pattern-matching using glob patterns. Some shells (such as the [[C shell]] and [[Bash_(Unix_shell)|Bash]]) support additional syntax known as [[alternation (string expansion)|alternation]] or [[brace expansion]]. Because it is not part of the glob syntax, it is not provided in <code>case</code>. It is only expanded on the command line before globbing. The Bash shell also supports the following extensions:<ref>{{cite web |title=Bash globs |url=https://mywiki.wooledge.org/glob |website=greg's bash knowledgebase |access-date=25 November 2019 |archive-date=2019-11-18 |archive-url=https://web.archive.org/web/20191118054712/http://mywiki.wooledge.org/glob |url-status=live }}</ref> * Extended globbing (extglob): allows other pattern matching operators to be used to match multiple occurrences of a pattern enclosed in parentheses, essentially providing the missing [[kleene star]] and alternation for describing regular languages. It can be enabled by setting the {{code|extglob}} shell option. This option came from ksh93.<ref name="bashpat"/> The GNU fnmatch and glob has an identical extension.<ref name=fnmatch3/> * globstar: allows <code>**</code> on its own as a name component to recursively match any number of layers of non-hidden directories.<ref name="bashpat"/> Also supported by the [[JavaScript]] libraries and [[Python (programming language)|Python]]'s glob.
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)