GLOB(1)

πŸ“¦ version 1.053, in alpine 3.24

πŸ’– 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 to foo bar (not bar 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 (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 over File::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 use qr// (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