What is the ** glob character?

Jwan622 picture Jwan622 · Sep 16, 2015 · Viewed 27.8k times · Source

I have this path in my react gulpfile:

var path = {
  HTML: 'src/index.html',
  ALL: ['src/js/*.js', 'src/js/**/*.js', 'src/index.html'],
  JS: ['src/js/*.js', 'src/js/**/*.js'],
  MINIFIED_OUT: 'build.min.js',
  DEST_SRC: 'dist/src',
  DEST_BUILD: 'dist/build',
  DEST: 'dist'
};

What is the double glob character?

I know what the single glob is... but what is the double? single glob

Answer

paxdiablo picture paxdiablo · Sep 16, 2015

It's almost the same as the single asterisk but may consist of multiple directory levels.

In other words, while /x/*/y will match entries like:

/x/a/y
/x/b/y

and so on (with only one directory level in the wildcard section), the double asterisk /x/**/y will also match things like:

/x/any/number/of/levels/y

with the concept of "any number of levels" also including zero (in other words, /x/**/y will match /x/y as one of its choices).


As an aside, as much as I hate to credit the mainframe with anything, I believe this has been used since the earlist days of MVS to allow selection of datasets at multiple levels :-)