Help answer threads with 0 replies.
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, 09: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, 09:25 AM   #2
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 464

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

ls -ld *|egrep "^d"
Old 03-20-2003, 11:27 AM   #3
Registered: Mar 2003
Location: Iowa, US
Distribution: Mint
Posts: 174

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, 11: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, 11: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, 01:40 PM   #6
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 464

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

Last edited by fsbooks; 03-20-2003 at 02: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 12:53 PM
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 08:19 PM
How to just list directories using ls command shazam75 Linux - Newbie 10 01-26-2006 03:34 PM
Get Directories with Command Line FTP? BLazeD Linux - Newbie 2 09-09-2004 03:47 AM
share directories from command line tarheel92x Linux - Networking 1 09-07-2004 10:09 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:41 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
Open Source Consulting | Domain Registration