Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash globstar matching after text

I really can't understand why pattern test**/*.ext matches test23/file.ext, but doesn't match test23/test/file.ext and test23/test/test/file.ext. Globstar should match all of this, shouldn't it?

like image 423
Anonym Avatar asked Feb 05 '26 12:02

Anonym


1 Answers

Here's man bash:

When the globstar shell option is enabled, and * is used in a pathname expansion context, two adjacent *s used as a single pattern will match all files and zero or more directories and subdirectories. If followed by a /, two adjacent *s will match only directories and subdirectories.

Since your ** is not a single pattern but rather a part of test**, it does not get the globstar treatment.

like image 160
that other guy Avatar answered Feb 08 '26 03:02

that other guy