Criando o cenário:
willian@willian:~/Desktop$ for i in 1 2 3;do > arq${i};doneAgora eu quero listar apenas os diretórios:
willian@willian:~/Desktop$ for i in 1 2 3;do mkdir dir${i};done
willian@willian:~/Desktop$ ls -l
drwxr-xr-x 5 willian willian 4096 May 25 00:56 ./
drwxr-xr-x 33 willian willian 4096 May 25 00:18 ../
-rw-rw-r-- 1 willian willian 0 May 25 00:56 arq1
-rw-rw-r-- 1 willian willian 0 May 25 00:56 arq2
-rw-rw-r-- 1 willian willian 0 May 25 00:56 arq3
drwxrwxr-x 2 willian willian 4096 May 25 00:56 dir1/
drwxrwxr-x 2 willian willian 4096 May 25 00:56 dir2/
drwxrwxr-x 2 willian willian 4096 May 25 00:56 dir3/
Em uma consulta rápida no man, descobri a opção -d
-d, --directory
list directory entries instead of contents, and do not dereference symbolic links
Resultado:
willian@willian:~/Desktop$ ls -dSolução:
.
willian@willian:~/Desktop$ ls -ld
drwxr-xr-x 5 willian willian 4096 May 25 00:56 .
willian@willian:~/Desktop$ ls -d */
dir1/ dir2/ dir3/
willian@willian:~/Desktop$ ls -dl */
drwxrwxr-x 2 willian willian 4096 May 25 00:56 dir1/
drwxrwxr-x 2 willian willian 4096 May 25 00:56 dir2/
drwxrwxr-x 2 willian willian 4096 May 25 00:56 dir3/