How to exclude this / current / dot folder from find "type d"
find . ! -path . -type d
For this particular case (.
), golfs better than the mindepth
solution (24 vs 26 chars), although this is probably slightly harder to type because of the !
.
To exclude other directories, this will golf less well and requires a variable for DRYness:
D="long_name"find "$D" ! -path "$D" -type d
My decision tree between !
and -mindepth
:
- script? Use
!
for portability. - interactive session on GNU?
- exclude
.
? Throw a coin. - exclude
long_name
? Use-mindepth
.
- exclude
I use find ./* <...>
when I don't mind ignoring first-level dotfiles (the *
glob doesn't match these by default in bash - see the 'dotglob' option in the shopt builtin: https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html).
eclipse tmp # find .../screen./screen/.testfile2./.X11-unix./.ICE-unix./tmux-0./tmux-0/default
eclipse tmp # find ./*./screen./screen/.testfile2./tmux-0./tmux-0/default