Bash — Find out folder names only

Typically if you type “ls -l” to list all folders and files you get the following output:

ls -l
total 0
drwxr-xr-x 2 frank staff 64 22 Dez 09:33 folder_01
drwxr-xr-x 2 frank staff 64 22 Dez 09:33 folder_02
drwxr-xr-x 2 frank staff 64 22 Dez 09:33 folder_03
drwxr-xr-x 2 frank staff 64 22 Dez 09:33 folder_04
drwxr-xr-x 2 frank staff 64 22 Dez 09:33 folder_05

To get folder names only, you can run the following command:

find . -maxdepth 1 -type d | awk -F / '{print $NF}' | sort
.
folder_01
folder_02
folder_03
folder_04
folder_05