[clug] list only directories

Hal Ashburner hal at ashburner.info
Tue Nov 19 23:38:28 MST 2013


cool, but won't show hidden dirs (neither does my script), the trailing
slashes, meh, mostly they won't matter.

Mr Anonymous suggests something similar to Andrew

find . -maxdepth 1 -type d -ls




On 20 November 2013 17:31, Andrew Janke <a.janke at gmail.com> wrote:

> ls -d */
>
> ?
>
> a
>
> PS: I suspect the difference between directories and directory entries
> is tripping you up..
>
> On 20 November 2013 16:22, Hal Ashburner <hal at ashburner.info> wrote:
> > Dear Clug,
> >
> > To list only directories I have a one line script ~/bin/lsd [1]
> >
> > #!/bin/bash
> > ARG="${1:-.}"
> > \ls ${ARG} | while read a; do if [[ -d ${ARG}/${a} ]]; then echo ${a};
> fi;
> > done
> >
> > so if i only want to see directories, that's what I see
> >
> > I've had it or something like it for years. Never given it much thought,
> > but it strikes me as really quite odd that ls, having 16536 different
> > options doesn't have one for just show me things of this type. Maybe I
> just
> > missed it? Reading manpages in depth is pretty painful.
> >
> > Do you good and talented people all do something similar? Are you doing
> > better? Have I missed a trick?
> >
> > Cheers,
> >
> >
> >
> > [1] it's called lsd as in ls for d - directories and in homage to the
> quip
> > about the two things that came out of Berkeley in the late 60s or early
> > 70s, but has nothing whatever to do with ratpoison.
> > --
> > linux mailing list
> > linux at lists.samba.org
> > https://lists.samba.org/mailman/listinfo/linux
>


More information about the linux mailing list