LinuxQuestions.org
Visit Jeremy's Blog.
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 06-19-2006, 01:41 PM   #1
anjanesh
Member
 
Registered: Sep 2004
Location: Navi Mumbai
Distribution: Ubuntu 12.04 64-bit
Posts: 230

Rep: Reputation: 30
Listing all directories only


I thought ls -d was the equivalent of DOS's DIR /AD - but its not showing the directories.
Any way to list directories only ?

Thanks
 
Old 06-19-2006, 01:50 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Code:
find . -type d -exec ls -d {} \;

or

ls -d .*"/" *"/"

or

find . -maxdepth 1 -type d

or

ls -al | grep ^d
 
Old 06-19-2006, 02:10 PM   #3
anjanesh
Member
 
Registered: Sep 2004
Location: Navi Mumbai
Distribution: Ubuntu 12.04 64-bit
Posts: 230

Original Poster
Rep: Reputation: 30
Cool ! How come theres no direct option in ls or some other command ? Why this combination methods only ?
 
Old 06-19-2006, 02:55 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Quote:
How come theres no direct option in ls or some other command ? Why this combination methods only ?
I don't know. It seems that just plain ls -d would work but it doesn't.
 
Old 06-20-2006, 01:16 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,287

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
or
ls -1F|grep '/'
 
Old 06-20-2006, 03:23 AM   #6
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 52
Maybe because in the unix philosophy a directory is also a file. Everything is a file in unix.
alias lsd='ls -la $* | grep ^d'
 
  


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
putty display loops on listing directories with many files, through expect script vineet.k Linux - General 5 03-13-2007 09:44 AM
Bash - listing directories tarja Programming 8 12-03-2005 04:03 PM
recursively listing directories full paths kubicon Linux - Newbie 2 02-22-2004 03:55 PM
proftpd...hangs before listing directories bstew007 Linux - Software 7 12-23-2002 02:57 AM
Display wide listing of files and directories only? northfield Linux - General 3 08-21-2002 06:28 PM


All times are GMT -5. The time now is 09:12 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