How to list only subdirectories?

To list only subdirectories within a directory, you can use the following command:

find /path/to/directory -type d -maxdepth 1
  • Replace /path/to/directory with the path of the directory you want to check.
  • The -type d option specifies that you want to find directories.
  • The -maxdepth 1 option limits the search to the immediate subdirectories, preventing it from listing deeper levels.

Alternatively, you can use:

ls -d /path/to/directory/*/

This command will also list only the subdirectories within the specified directory.

0 Comments

no data
Be the first to share your comment!