LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 03-20-2003, 08:15 AM   #1
geraldomanaus
Member
 
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
fsbooks
Member
 
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: fedora, slackware, suse
Posts: 447

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

ls -ld *|egrep "^d"
 
Old 03-20-2003, 10:27 AM   #3
PhilD
Member
 
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,

PhilD
 
Old 03-20-2003, 10:36 AM   #4
Crashed_Again
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

So:

ls -d

will give you directories only instead of files AND directories.
 
Old 03-20-2003, 10:56 AM   #5
m0rl0ck
Member
 
Registered: Nov 2002
Distribution: A totally 133t distro :)
Posts: 358

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


If it isnt already aliased to "lsd".
 
Old 03-20-2003, 12:40 PM   #6
fsbooks
Member
 
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: fedora, slackware, suse
Posts: 447

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

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


Reply


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 15 08-03-2013 05:20 PM
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 01:23 PM.

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