glob pattern

A pattern that matches names using * for any run of characters, a question mark for one character and [abc] for one of a set.

In more detail

Shells expand glob patterns into matching file names before running a command, and many tools, such as ignore files and test runners, use the same patterns to select files. Many tools also accept ** to match any number of folders, as in src/**/*.ts. A glob is simpler than a regular expression: a star in a glob means anything, while in a regular expression it means repeat the previous item. Quote a pattern on the command line when the program, not the shell, should expand it.

Examples

ls *.md
find . -name "*.log"
turbo.json outputs: ["dist/**", ".next/**"]
*.log
docs/**/scratch.md (Git adds ** for any number of directories)
Path(".").glob("*.py") in Python; the glob module does the same with strings.
"include": ["src/**/*"]

Related terms

Taught in

References

Certification courses