With zsh
:
print -rC1 -- **/*(N/)
(zsh globs skip hidden files by default).
Or to do anything with those dirs:
for dir (**/*(N/)) anything with $dir
or, if anything
can take more than one file at a time, with GNU xargs
or compatible:
xargs -r0a <(print -rNC1 -- **/*(N/)) anything with
POSIXly:
LC_ALL=C find . -name '.?*' -prune -o -type d -print
LC_ALL=C
is needed otherwise it would fail to skip hidden dirs whose name contains sequences of bytes that don't form valid character in the user's locale. See also how the order of the predicates makes sure we avoid applying -type d
(which potentially involves an extra expensive lstat()
system call) on those files whose name starts with .
.
That one also outputs .
(the current working directory), add a ! -name .
before -type
if you don't want it or change it to:
LC_ALL=C find . ! -name . \( -name '.*' -prune -o -type d -print \)
Do do anything with the files, replace -print
with -exec anything with {} ';'
or -exec anything with {} +
if anything
can take more than one file at once.