-   Linux - Newbie (
-   -   How may I list only the directories in command line? (

geraldomanaus 03-20-2003 08:15 AM

How may I list only the directories in command line?
Hello people,

What is the command that I can use to list only the directories in the command line (console) on Linux?
I tried to read the "ls man page" but didn`t find anything. Thanks to all.

fsbooks 03-20-2003 08:25 AM

This works for a long listing:

ls -ld *|egrep "^d"

PhilD 03-20-2003 10:27 AM

Wow, that is a little cryptic! Geraldomanaus, sorry but I don't have an easier one for you. I would suggest though, if this provides the desired output, put an alias in your .bashrc file so you can just use a something like 'lld' or something similar. You can make a lot of custom commands via your .bashrc file.

Just a suggestion,


Crashed_Again 03-20-2003 10:36 AM

To simplify things, you only have to add the -d switch. In the man pages for ls it says:

−d, −−directory
list directory entries instead of contents


ls -d

will give you directories only instead of files AND directories.

m0rl0ck 03-20-2003 10:56 AM

"ls -d */"

If it isnt already aliased to "lsd".

fsbooks 03-20-2003 12:40 PM

That works. I tend to go for the pipes with regular expressions.

All times are GMT -5. The time now is 01:16 AM.