What expands to all files in current directory recursively?

前端 未结 5 1293
無奈伤痛
無奈伤痛 2020-11-27 13:32

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

5条回答
  •  春和景丽
    2020-11-27 14:00

    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.

提交回复
热议问题