[PLUG] ls -d does not work as it should

Steve Christiansen steveshome at comcast.net
Mon Jun 25 23:56:32 UTC 2018


On 6/25/2018 4:22 PM, Rich Shepard wrote:

> Steve,
>
>   I interpreted the man page as using the -d option to list only
> subdirectories of the cwd.
>
>   Why would ls have an option to tell you you're in the current working
> directory?

I agree that -d by itself is next to useless, but it's helpful with 
wildcards.
To list the names of files and directories beginning with, say, the 
letter "a"
ls -d a*
The -d prevents the command from listing directories' contents instead 
of their names.

>
>   What option would you use to list only subdirectories and not files 
> in the
> cwd or the subdirectories?

I don't know if ls will do that without some kind of filter.
I usually do something like
find * -type d -prune
The -prune prevents recursion all the way down the directory tree.

>
> Rich
> _______________________________________________
> PLUG mailing list
> PLUG at pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>




More information about the PLUG mailing list