Hacker News new | ask | show | jobs
by codegeek 4916 days ago

    alias lsd="ls -ltrF | grep ^d"
Helps me quickly list only directories. Any better alternatives ?
7 comments

Using `find` is nice to get just directories:

$ find . -type d -maxdepth 1

I use:

% ls -d */

ls -al | grep ^d
(Fails if a directory has a linefeed in its name followed by a 'd'. :-)

  find . -type d
edit: for the same output as your command you can use:

  dir -l
Dunno what "better" means, but this also works:

find -maxdepth 1 -type d

seconded. what I have always used
Depends on the shell. In zsh (with EXTENDED_GLOB): *(/) matches only directories.
I usually

    alias lsd='ls -d */'
ls -l | grep drw

I know, it's a bad habit

echo */ (perfect when your unable to fork)