Glob - Globbing (Wildcard expression)



Glob is NOT a regular language but is wildly used to define a set of filenames with wildcard characters.

For instance, Bash provide globbing on filenames.

Wildcard / Syntax

The syntax is different by implementation and below are the most known pattern.

  • The matchs of the wildcard characters is explained below
  • All other characters match themselves.


An asterisk (also known as star) , *, matches any number of characters (including none).


  • *.html – Matches all strings that end in .html

Double Asterix

Two asterisks, **, works like * but crosses directory boundaries (ie complete paths) in a file system.


  • The recursive globbing is always located before the last name in the path

Syntax and parsing rule: if the two asterisks, ** are followed by a /, this pattern will match only directories and subdirectories. See globstar in bash


Question mark

A question mark, ?, matches exactly one character.


  • ??? – Matches all strings with exactly three letters or digits
  • a?*.java – Matches any string beginning with a, followed by at least one letter or digit, and ending with .java


Braces specify a collection of subpatterns. For example:

  • {sun,moon,stars} matches “sun”, “moon”, or “stars”.
  • {temp*,tmp*} matches all strings beginning with “temp” or “tmp”.
  • *.{htm,html,pdf} – Matches any string ending with .htm, .html or .pdf
  • {foo*,*[0-9]*} – Matches any string beginning with foo or any string containing a numeric value

Square brackets

Square brackets convey a set of single characters or, when the hyphen character (-) is used, a range of characters.

  • [aeiou] matches any lowercase vowel.
  • [0-9] matches any digit.
  • [A-Z] matches any uppercase letter.
  • [a-z,A-Z] matches any uppercase or lowercase letter.
  • [!abc] exclusion does not match the set of characters abc
  • Within the square brackets, *, ?, and \ match themselves.


  • *[0-9]* – Matches all strings containing a numeric value


To match *, ?, or the other special characters, you can escape them by using the backslash character, \. For example:

  • \\ matches a single backslash,
  • \? matches the question mark.

Note: If you are typing the glob pattern at the console and it contains one of the special characters, you must:

  • put the pattern in quotes (“*”),
  • use the backslash (\*),
  • or use whatever escape mechanism is supported at the command line.


A possible definition is that a string is a wildcard pattern when it contains one of the characters

  • ? to matches any single character
  • * to matches any string
  • [ for character class definition
  • { to define a list of pattern


globbing in other languages


See filename expansion example



Documentation / Reference

Discover More
Bash Liste Des Attaques Ovh
Bash - pathname expansion (Filename expansion)

pathname or filename expansion is an expansion (code replacement at runtime) that replaces globbing wildcard by pathname. pathfile name The asterisk character matches every filename in a given...
Oracle Platform Structured Unstructured Data
Endeca - Wildcard Search

Wildcard Search is the ability to match user query terms to word fragments. See Wildcard Search doc
Map Of Internet 1973
FTP - Glob (Globbing)

Toggle metacharacter expansion of local file names. Globbing permits the use of the asterisk () and question mark (?) as wildcard characters in local file or path names. By default, globbing is on....
Bash Liste Des Attaques Ovh
How to use Regular expression (regex) in Bash?

This article shous you how to use regular expression in Bash This example shows you how you can capture a Group to extract text. Example where we will extract a part of a file name When the...
Bash Liste Des Attaques Ovh
Linux - File

Linux file management See Using Parameters Expansion Removal From a path string where the file does not exist dirname returns the first parent of an existing path file. ...
Multilingual Regular Expression Syntax (Pattern)

Regular expression are Expression that defines a pattern in text. This is therefore a language that permits to define structure of a text. They are a mathematically-defined concept, invented by Stephen...
Card Puncher Data Processing
PHP - File System

operation in php All files are read and becomes bytes (for a string/ text, by default in the ASCII character set). file_get_contents from an URL from the same directory than the script ...
Storybook Actions
React - Storybook (Component workbench)

Storybook is a component workbench where you write story. A story is a single state of your component. Technically, it is a function that returns something that can be rendered to screen. UI component...
Regexp - Star

Star () is a quantifier that matches 0 or more occurrences of the preceding element. See Kleene_closureKleene closure (known as Kleene star) OS shellBashGlob star ...
Card Puncher Data Processing
Shell Data Processing - (WC|Word Count) command (Line count)

The wc command is a filter that prints on one line sequentially the number of: newlines (lines), words, and characters from: files or from an input stream when: no FILE is specified or...

Share this page:
Follow us:
Task Runner