What is glob?

Glob or shell globbing refers to the process of matching glob patterns to files in the filesystem. Best to illustrate it with an example: bash shell command cp *.jpg ./thumbnails will copy all files that have .jpg extension to the thumbnails folder. In that context *.jpg is the glob pattern and it will match all the files in the current working directory that have .jpg extension. Think of it as a pattern matching for the filesystem.

What is globster.xyz?

globster.xyz is a tool to test and visualise glob pattern matching. Type your glob pattern in the input field above and all matched files will be highlighted in blue in the tree directory structure. Use it to debug when your glob does not work or to experiment and learn from the provided examples. minimatch (version 3.0.4) JavaScript library is used to evaluate glob patterns on this website.

Where is globbing used?

Globbing was first introduced in unix system. It is widely used in many tools these days. Gitignore file of the git version control system is one example. Patterns are used to exclude certain files and folders from being version controlled.

Syntax

Syntax depends on the particular implementation. Minimatch used by this website supports basic wildcards (?*) as well as : brace expansion, extended glob matching and globstar. Go to glob examples section for minimatch examples and syntax details. Details are based on the minimatch documentation and sh documentation.

Glob implementations

There are many implementations in almost every programming language.

Javascript: minimatch, micromatch, extglob

Python: glob module

Linux: glob

About the author

I am on Twitter at @CDomajno. Feel free to drop me a message. Also check out my other projects scatter plot maker and save the date card templates.

If you have any question or suggestions please go to ask question section and start the discussion.