In zsh you can qualify globs with file type assertions e.g. *(/)
matches only directories, *(.)
only normal files, is there a way to do the same thing in bash without resorting to find?
you can try
ls -ltrd */ #match directories using -d and the slash "/"
or
echo */
or
for dir in */
do
...
done
If you need to do it recursive, and you have Bash 4+
$ shopt -s globstar
$ for dir in **/*/; do echo $dir; done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With