Glob Patterns

2792 days ago, 0 views.

A glob is a short expression that lets you select a bunch of files. 99% of the time, there’s an asterisk involved.

Here’s a (non exhaustive) list of the most useful patterns.

Depends of your glob engine, it could support more or less complex expressions. The follow list is tested using zsh.

List every file in the folders directly below the test folder

$ ls test/*

List every file in every folder two levels below the test folder

$ ls test/*/*

List every file anywhere below the test folder

$ ls test/**/*

List every file that ends in .json in every folder at any level below the test folder

$ ls test/**/*.json

List every file that ends in .json or .js in every folder at any level below the test folder

ls test/**/*.(json|js)

Bibliography

Kiko Beats

Kiko Beats