How to list only directories?

To list only directories in bash, you can use the ls command combined with the -d option and a wildcard. Here’s how you can do it:

ls -d */

This command will list all directories in the current directory by matching the pattern */, which represents all items that are directories.

Alternatively, you can use the find command to list only directories:

find . -type d -maxdepth 1

This command will find and list all directories in the current directory (-maxdepth 1 ensures it does not go into subdirectories).

0 Comments

no data
Be the first to share your comment!