Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-20-2003, 08:15 AM   #1
Registered: Nov 2002
Location: Amazonas/Brasil (Rain Forest)
Distribution: GNU/Slackware
Posts: 43

Rep: Reputation: 15
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.
Old 03-20-2003, 08:25 AM   #2
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 457

Rep: Reputation: 41
This works for a long listing:

ls -ld *|egrep "^d"
Old 03-20-2003, 10:27 AM   #3
Registered: Mar 2003
Location: Iowa, US
Distribution: Gentoo!!, Mandrake 9.1
Posts: 170

Rep: Reputation: 30
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,

Old 03-20-2003, 10:36 AM   #4
Senior Member
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
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.
Old 03-20-2003, 10:56 AM   #5
Registered: Nov 2002
Distribution: A totally 133t distro :)
Posts: 358

Rep: Reputation: 31
"ls -d */"

If it isnt already aliased to "lsd".
Old 03-20-2003, 12:40 PM   #6
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 457

Rep: Reputation: 41
That works. I tend to go for the pipes with regular expressions.

Last edited by fsbooks; 03-20-2003 at 01:41 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] command to list directories only frieza Linux - Software 16 04-01-2016 11:53 AM
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
How to just list directories using ls command shazam75 Linux - Newbie 10 01-26-2006 02:34 PM
Get Directories with Command Line FTP? BLazeD Linux - Newbie 2 09-09-2004 02:47 AM
share directories from command line tarheel92x Linux - Networking 1 09-07-2004 09:09 PM

All times are GMT -5. The time now is 11:30 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration