What expands to all files in current directory recursively?

Viewed 39571

I know **/*.ext expands to all files in all subdirectories matching *.ext, but what is a similar expansion that includes all such files in the current directory as well?

5 Answers

Why not just use brace expansion to include the current directory as well?

./{*,**/*}.ext

Brace expansion happens before glob expansion, so you can effectively do what you want with older versions of bash, and can forego monkeying with globstar in newer versions.

Also, it's considered good practice in bash to include the leading ./ in your glob patterns.

Related