LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 14.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: 61
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 14.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: 61
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
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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: 57
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration