GLOB(1)
π GLOB(1) β the glob glow-up π
okay bestie, welcome to the glob manual page from the User Contributed Perl Documentation crew π«Ά. This is the little command that does pathname matching, and yes, itβs giving iconic filename-expansion energy. Letβs get into it, no cap β¨.
β¨ NAME β¨
glob β output pathnames matching a pattern π
π SYNOPSIS π
On the command-line:
glob 'eenie{meenie,mynie,moe}*.[ch]'
π¦ DESCRIPTION π¦
So back when this program was originally created, perl did not have a builtin glob feature and would rely on the csh to do the work for it π. Then with Perl v5.6 in March 2000, the File::Glob module has done that work without interacting with csh β slay for autonomy, honestly π.
πΈ Pattern Matching Syntax for Filename Expansion πΈ
The expressions you pass as arguments to glob must adhere to csh/tcsh pattern-matching syntax for wildcard filename expansion (also known as globbing) π§. Unquoted words containing an asterisk (*), question-mark (?), square-brackets ([...]), or curly-braces ({...}), or beginning with a tilde (~), are expanded into an alphabetically sorted list of filenames, as follows:
*β matches any (zero or more) characters π«?β matches any single character π―[...]β matches any single character in the given character class. The character class is the enclosed list(s) or range(s). A list is a string of characters. A range is two characters separated by a dash (-), and includes all the characters in between the two characters given (inclusive). If a dash (-) is intended to be part of the character class it must be the first character given π{str1,str2,...}β expands the given βword-setβ to each string (or filename-matching pattern) in the comma-separated list. Unlike the pattern-matching expressions above, the expansion of this construct is not sorted. For instance,{foo,bar}expands tofoo bar(notbar foo) π. As special cases, unmatched{and}, and the βempty setβ (the string{}) are treated as ordinary characters instead of pattern-matching meta-characters. A backslash (\) may be used to escape an opening or closing curly brace, or the backslash character itself. Note that word-sets may be nested! πͺ~β the home directory of the invoking user as indicated by the value of the variable$HOMEπ~usernameβ the home directory of the user whose login name is 'username', as indicated by the password entry for the named user π
Only the patterns *, ? and [...] imply pattern matching; an error results if no filename matches a pattern that contains them. When a period or βdotβ (.) is the first character in a filename or pathname component, it must be matched explicitly. The filename component separator character (e.g., / or slash) must also be matched explicitly. Periodt. π
βοΈ OPTIONS βοΈ
-0β when the first argument is-0(a minus sign followed by the number zero), then a NUL character (\0) is used to separate the expanded words and/or filenames when printing them to standard output. Otherwise a newline is used as the word/filename output separator π.
π RETURNS π
When glob is invoked as a script from the command-line, the exit-status returned will be 0 if any files were matched or word-sets were expanded; 1 if no files/word-sets were matched/expanded; and 2 if some other kind of error occurred. Track the vibe check by number, bestie π’.
π¨ DIAGNOSTICS π¨
If no filenames are matched and pattern-matching characters were used (*, ?, or [...]), then an error message of No Match is issued π. If a userβs home directory is specified using tilde-expansion (e.g., ~username) but the corresponding username or their home directory cannot be found, then the error message Unknown user: username is issued π.
π COPYRIGHT π
Copyright (c) 1997-2025 Marc Mengel. All rights reserved. π«Ά
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself π.
π AUTHOR π
Marc Mengel <mengel@fnal.gov> β¨
π§Ύ REVISIONS π§Ύ
- brian f foy
<briandfoy@pobox.com>β v2.1 February 2025: Reimplement this as a thin layer overFile::Glob::csh_glob. This program was written before that was a core module, but had several edge cases where it would crash π. - Brad Appleton
<bradapp@enteract.com>β v1.2 March 1999: Modified to useqr//(and some other minor speedups), to explode subexpressions in curly braces (a la csh -- rather than using just plain alternation), and made callable as a standalone script π.
π thatβs the whole page, bestie β perl v5.42.2, dated 2026-02-15, signing off as GLOB(1) π
β¨
π¦ where this page comes from
- alpine 3.24: perl-power-tools-doc 1.053-r1 Β· GPL-2.0-or-later AND Artistic-1.0-Perl AND Artistic-2.0 AND BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms