67

I was reading here on Stack Overflow about ** in a path, as in this example:

src/js/**/*.js

I would like to ask if " ** " means "any nested directory" please?!

Ariam1
  • 1,673
  • 2
  • 13
  • 32
  • 4
    If I'm not mistaken, `src/js/**/*.js` matches all `.js` files below the `src/js/`directory, at any depth, regardless of the sub-directory structure. – Jeremy Thille Oct 03 '17 at 14:59
  • Possible duplicate of [Two asterisks in file path](https://stackoverflow.com/questions/8532929/two-asterisks-in-file-path) – Liam Feb 01 '18 at 11:01
  • 1
    Possible duplicate of [What is the \*\* glob character?](https://stackoverflow.com/questions/32604656/what-is-the-glob-character) – paxdiablo Aug 28 '18 at 00:41

2 Answers2

79

The double star in this case means all folders within the current folder, with the current folder being src/js

So in full, find all files with a .js extension, in all subfolders of src/js

danwellman
  • 9,068
  • 8
  • 60
  • 88
27

The double asterisks are placeholders or instructions to the recursive interpreter to go through the files and folders. It is a simple, recursive wildcard while only one asterisk means all without recursion.

'**/*.js'; All files with the extension .js from here onwards.

'lib/**/*.js'; All files with the extension .js in the folder lib and its subfolders.

'js/**'; All files in the folder js and its subfolders.

Maik Lowrey
  • 15,957
  • 6
  • 40
  • 79