chenglou
chenglou

Reputation: 3640

Difference between dir/**/* and dir/*/* in Unix glob pattern?

It seems that the output are the same when I echoed it.

I also tested other commands such as open, but the results from both are the same.

Upvotes: 2

Views: 411

Answers (1)

user4815162342
user4815162342

Reputation: 155515

In traditional sh-style pattern matching, * matches zero or more characters in a component of the file name, so there is no difference between *, **, and ***, either on its own or as part of a larger pattern.

However, there are globbing syntaxes that assign a distinct meaning to **. Pattern matching implemented by the Z shell, for example, expands x/**/y to all file names beginning with x/ and ending in /y regardless of how many directories are in between, thus matching all of x/y, x/subdir/y, x/subdir1/subdir2/y, etc. This syntax was later implemented by bash, although only enabled when the globstar configuration option is set by the user.

Upvotes: 4

Related Questions