LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-08-2005, 11:41 AM   #1
dr3vi1
LQ Newbie
 
Registered: Jul 2004
Posts: 3

Rep: Reputation: 0
Help with syntax


Hello, I am trying to find out the comand for listing the Directorys not the files.

the ls command will list the files and there are many other manipulations of the ls command that list files, but what I'm looking for is a command that will list the directorys only?

Is there such a beast?

I've googled this thing to death.

Thanks Kevin
 
Old 08-08-2005, 11:51 AM   #2
jeffk42
Member
 
Registered: Mar 2005
Location: Orlando, FL USA
Distribution: Fedora Core 13 x86_64 / RHEL 5.3
Posts: 76

Rep: Reputation: 15
I can't fully help you with this... I'm not sure how to do it.

But (and I don't know if this will help at all) you could try tree -d. That'll list all directories and subdirectories from wherever you are. tree -d -L 1 will list just the directories, without traversing the subdirectories.

Last edited by jeffk42; 08-08-2005 at 11:53 AM.
 
Old 08-08-2005, 11:55 AM   #3
jeffk42
Member
 
Registered: Mar 2005
Location: Orlando, FL USA
Distribution: Fedora Core 13 x86_64 / RHEL 5.3
Posts: 76

Rep: Reputation: 15
Ooh... OK this is better.

tree -d -L 1 -i

The -i option removes the indentation. So it looks like a vertical ls.
 
Old 08-08-2005, 11:56 AM   #4
dr3vi1
LQ Newbie
 
Registered: Jul 2004
Posts: 3

Original Poster
Rep: Reputation: 0
We'll try that now, thanks so much!
Let you know how it goes

Kevin
 
Old 08-08-2005, 03:32 PM   #5
rstewart
Member
 
Registered: Feb 2005
Location: Sunnyvale, CA
Distribution: Ubuntu
Posts: 205

Rep: Reputation: 38
Hi,

ls -d will cause the ls command to only display directories. Please see the ls man page (man ls) for a complete write up on all of the ls command line options that are available.
 
Old 08-08-2005, 07:48 PM   #6
JDaniels
LQ Newbie
 
Registered: Jun 2004
Location: Salt Lake City, UT
Distribution: Slackware
Posts: 24

Rep: Reputation: Disabled
ls -l does not list all the directories in the current directory. It lists a specified directory as an entry, not the contents as it normally does. To list only the directories you can use ls -l | grep ^d
 
Old 08-09-2005, 10:40 AM   #7
rstewart
Member
 
Registered: Feb 2005
Location: Sunnyvale, CA
Distribution: Ubuntu
Posts: 205

Rep: Reputation: 38
Quote:
ls -l does not list all the directories in the current directory. It lists a specified directory as an entry, not the contents as it normally does. To list only the directories you can use ls -l | grep ^d
the -l option instructs the ls command to display information using the "l"ong listing format. you do not need to pipe anything to grep. As I previously stated, all you need to do is to use the -d option. The -d option instructs the ls command to display "d"irectories. Again, you can take a look at the man page for the ls command to find out what all of the options do.
 
Old 08-09-2005, 11:20 AM   #8
JDaniels
LQ Newbie
 
Registered: Jun 2004
Location: Salt Lake City, UT
Distribution: Slackware
Posts: 24

Rep: Reputation: Disabled
Output of ls -d :

Code:
crash:<~>ls -d
.
crash:<~>
Ouput of ls -l | grep ^d :

Code:
crash:<~>ls -l | grep ^d
drwxrwxr-x    3 owner     mixed        4096 Aug  5 17:05 Local Folders
drwxr-xr-x    5 owner     mixed        4096 Aug  7 17:28 OpenOffice.org1.1.0
drwxrwxr-x    3 owner     mixed        4096 Jul 22 13:37 cdsSkill
drwxrwxr-x    7 owner     mixed        4096 Apr  1 09:22 ecad
drwxrwxr-x   10 owner     mixed        4096 Jul 15 15:08 files
drwxrwxr-x    7 owner     mixed        4096 Mar  7 10:29 herc
drwxrwxr-x    7 owner     mixed        4096 Mar  7 11:30 myproj
drwxrwxr-x    6 owner     mixed        4096 Aug  7 16:24 opus50
drwxrwxr-x    2 owner     mixed        4096 Mar 30 15:29 shellscripts
drwxrwxr-x    9 owner     mixed        4096 Jul 14 17:03 usr
crash:<~>
Output of ls -la | grep ^d :
Code:
crash:<~>ls -la | grep ^d
drwxrwxr-x   39 owner     mixed        4096 Aug  9 09:07 .
drwxr-xr-x    3 root     wheel           0 Aug  8 16:28 ..
drwxr-xr-x    2 owner     mixed        4096 Mar 11 15:56 .acrobat
drwx------    3 owner     mixed        4096 May 20 15:05 .adobe
drwxr-x---    2 owner     mixed        4096 Jun 17 15:32 .ami
drwx------    2 owner     mixed        4096 Jul 14 09:20 .elinks
drwxrwxr-x    6 owner     mixed        4096 Jun  8 09:11 .fullcircle
drwxrwxr-x    5 owner     mixed        4096 Aug  7 17:49 .fvwm
drwx------    5 owner     mixed        4096 Aug  5 10:00 .gaim
drwx------    2 owner     mixed        4096 Aug  7 17:30 .gconf
drwx------    2 owner     mixed        4096 Aug  7 17:30 .gconfd
drwxrwxr-x   17 owner     mixed        4096 Jun  9 15:29 .gimp-1.2
drwxr-xr-x    3 owner     mixed        4096 Mar  7 11:44 .gnome
drwxr-xr-x    4 owner     mixed        4096 Mar 29 15:53 .gnome2
drwx------    2 owner     mixed        4096 Mar 29 15:53 .gnome2_private
drwxrwxr-x    4 owner     mixed        4096 May 25 11:06 .java
drwxrwxr-x    4 owner     mixed        4096 Mar 17 10:33 .jpi_cache
drwxr-xr-x    3 owner     mixed        4096 Apr 12 09:12 .kde
drwx------    3 owner     mixed        4096 Mar 28 17:39 .macromedia
drwxr-xr-x    2 owner     mixed        4096 May 24 16:11 .mcop
drwxrwxr-x    8 owner     mixed        4096 Jun  8 16:56 .mozilla
drwxrwxr-x    4 owner     mixed        4096 Mar  7 10:11 .mplayer
drwxrwxr-x    2 owner     mixed        4096 Jun 23 15:34 .nedit
drwxrwxr-x    3 owner     mixed        4096 Mar  7 11:26 .netscape
drwxrwxr-x    3 owner     mixed        4096 Mar  7 11:26 .netscape6
drwxrwxr-x    2 owner     mixed        4096 Apr 12 09:12 .qt
drwxr-xr-x    3 owner     mixed        4096 Mar  8 14:27 .ssh2
drwxrwxr-x    3 owner     mixed        4096 Jun 17 10:10 .stella
drwxr-xr-x    4 owner     mixed        4096 Jun  6 16:32 .xmms
drwxrwxr-x    3 owner     mixed        4096 Aug  5 17:05 Local Folders
drwxr-xr-x    5 owner     mixed        4096 Aug  7 17:28 OpenOffice.org1.1.0
drwxrwxr-x    3 owner     mixed        4096 Jul 22 13:37 cdsSkill
drwxrwxr-x    7 owner     mixed        4096 Apr  1 09:22 ecad
drwxrwxr-x   10 owner     mixed        4096 Jul 15 15:08 files
drwxrwxr-x    7 owner     mixed        4096 Mar  7 10:29 herc
drwxrwxr-x    7 owner     mixed        4096 Mar  7 11:30 myproj
drwxrwxr-x    6 owner     mixed        4096 Aug  7 16:24 opus50
drwxrwxr-x    2 owner     mixed        4096 Mar 30 15:29 shellscripts
drwxrwxr-x    9 owner     mixed        4096 Jul 14 17:03 usr
crash:<~>
Man entry for ls:
Code:
...
-a, --all
              do not hide entries starting with .
...
-d, --directory
              list directory entries instead of contents
...
-l     use a long listing format
...

Last edited by JDaniels; 08-09-2005 at 11:26 AM.
 
  


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
syntax SmithSmith123 Linux - Newbie 2 11-17-2005 05:45 PM
Help with lp syntax slick_willie Programming 2 02-03-2005 08:18 PM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 07:09 PM
syntax lynger Linux - Software 6 12-02-2003 02:03 AM
C syntax help please ... DarkDrive Programming 2 08-07-2003 05:13 PM


All times are GMT -5. The time now is 11:03 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration