Match all files under all nested directories with shell globbing

后端 未结 6 1058
星月不相逢
星月不相逢 2021-02-03 23:35

Is there a way to use shell globbing to identify nested directories?

so if I have dir/dir1/dir2/dir3/dir4/dir5/.. and I have files under all of them, what is the equival

6条回答
  •  孤街浪徒
    2021-02-04 00:04

    In Bash 4, with shopt -s globstar, and zsh you can use **/* which will include everything except hidden files. You can do shopt -s dotglob in Bash 4 or setopt dotglob in zsh to cause hidden files to be included.

    In ksh, set -o globstar enables it. I don't think there's a way to include dot files implicitly, but I think **/{.[^.],}* works.

提交回复
热议问题