Will be expanded into:

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 place card maker.


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

? * / ** {a,b} ?(a|b) *(a|b) +(a|b) @(a|b) !(a|b)
Matches single character. Matches any string. Path separator. Feature known as globstar. Matches all files and zero or more directories and subdirectories. If followed by a /it matches only directories and subdirectories. To work that way it must be the only thing inside the path part e.g. /myapp/**.js will not work that way. Feature known as brace expansion. Expression inside curly braces is expanded into multiple patterns e.g. **/*.{b,c} will be expanded into **/*.b and **/*.c. The final result is the union of checking both patterns. Also brace sets like **/{a..c} will be expanded into **/a**/b**/c. Syntax of the extended glob matching feature (extglob). Matches zero or one occurrence of the given patterns. Syntax of the extended glob matching feature (extglob). Matches zero or more occurrences of the given patterns. Syntax of the extended glob matching feature (extglob). Matches one or more occurrences of the given patterns. Syntax of the extended glob matching feature (extglob). Matches one of the given patterns. Syntax of the extended glob matching feature (extglob). Matches anything except one of the given patterns.
  • /myapp/config/* All files inside config directory
  • **/*.png All .png files in all directories
  • **/*.{png,ico,md} All .png, .ico or .md files in all directories
  • /myapp/src/**/*.ts All .ts files inside src directory (and all its subdirectories)
  • **/!(*.module).ts All .ts files but not .module.ts
To change files structure edit paths below and then click apply button.
apply