Discussion: list folders only!
Afficher un message
Vieux 24/03/2008, 15h50   #10
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: list folders only!

2008-03-24, 05:37(-05), Salve Håkedal:
[...]
> In bash:
> $ ls -d */


should be ls -d -- */

> or as I prefer:
> $ ls -1d */


It works in most shells, not only bash. But note that it lists
directories and symlinks to directories, it also adds a / to the
end of every file name.

zsh has globbing qualifiers to select files of certain types or
with certain attributes:

ls -ld -- *(/)

will select directories only.

ls -ld -- *(-/)

for directories or symlinks to directories.

ls -ld -- *(D-/)

also includes dot-dirs (hidden directories).

ls -ld -- *(oND-/)

to disable the sorting done by zsh (ls does the sorting already
anyway)

With find:

find . ! -name . -prune ! -name '.*' -type d -print

Or:

find . ! -name . -prune ! -name '.*' -follow -type d -print
(to include symlinks to directories)

or:

find . ! -name . -prune -follow -type d -print
(to include hidden dirs).


--
Stéphane
  Réponse avec citation
 
Page generated in 0,05168 seconds with 9 queries