bash: list only subdirectories


klapse

Central Scrutinizer
Joined
Aug 30, 2012
Messages
1,932
Location
Germany
When I'm working in the shell, I frequently want to list only subdirectories of the current working directory. If you want to do this just add the following line to your ~/.bashrc


alias lsd="ls -1Fd * |grep '/'"


Then typing "lsd" at the bash prompt will get you a list of directories.


HTH, cheers!
 
That find command recurses to list subdirectories of subdirectories, not just the subdirectories of the current working directory.
 
find -maxdepth 1 -type d -printf '%P\n'

Or with output similar to your command:

find -maxdepth 1 -type d -printf '%P\n' | xargs ls -1Fd
 
Thanks Klaspe!, I like finding these quick *nix tricks.
 
Back
Top