LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 08-15-2006, 05:01 AM   #1
LinuxLover
Member
 
Registered: Feb 2004
Distribution: Centos 7 x86_64 , Rocky Linux 8 (aarch64)
Posts: 196

Rep: Reputation: 32
how to view only directories with ls


hello

I want to list only directories (not files) in my current directory with ls command which switch will be used ?

#ls -????

Last edited by LinuxLover; 08-15-2006 at 05:03 AM.
 
Old 08-15-2006, 05:04 AM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Code:
ls -d
lsd, of course

Of course you would have learned that by reading a few lines from
Code:
man ls
So NEXT TIME please read the man page first...
 
Old 08-15-2006, 05:54 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Use "ls */ -d"
or
"find ./ -maxdepth 1 -type d"
 
Old 08-16-2006, 10:46 AM   #4
koodoo
Member
 
Registered: Aug 2004
Location: a small village faraway in the mountains
Distribution: Fedora Core 1, Slackware 10.0 | 2.4.26 | custom 2.6.14.2, Slackware 10.2 | 11.0, Slackware64-13
Posts: 345

Rep: Reputation: 33
Here's another one:
Code:
ls -l | grep ^d
 
Old 08-16-2006, 05:49 PM   #5
Daws
Member
 
Registered: May 2006
Location: UK
Distribution: Debian
Posts: 447

Rep: Reputation: 39
Just thought I'd add that if you want to know the size of what they contain use:

Code:
du -h --max-depth 1
 
Old 09-15-2006, 11:55 AM   #6
ZachFSW
Newbie
 
Registered: Sep 2006
Posts: 0

Rep: Reputation: 0
I would suggest using anything but the very first suggestion

Code:
ls */ -d


The difference between that - and the other three is pretty clear.


[HTML]root@zach [~]# ls -d */
chkrootkit// cpanel3-skel// down// mytop// public_ftp// public_html// work//[/HTML]





Code:
root@zach [~]# find ./ -maxdepth 1 -type d
./
./.cpmysqlrpm
./.spamassassin
./cpanel3-skel
./.MirrorSearch
./work
./.wapi
./down
./public_html
./mytop
./.cpcpan
./chkrootkit
./.cpobjcache
./.cpanel-datastore
./.gnupg
./.gconfd
./public_ftp
./.ssh


Code:
root@zach [~]# du -h --max-depth 1
332K    ./.cpmysqlrpm
20K     ./.spamassassin
12K     ./cpanel3-skel
268K    ./.MirrorSearch
440M    ./work
4.0K    ./.wapi
80K     ./down
8.0K    ./public_html
236K    ./mytop
1.1M    ./.cpcpan
348K    ./chkrootkit
16K     ./.cpobjcache
40K     ./.cpanel-datastore
120K    ./.gnupg
4.0K    ./.gconfd
4.0K    ./public_ftp
8.0K    ./.ssh
450M    .


Code:
root@zach [~]# ls -l | grep ^d
drwxrwxrwx  19 nobody root    143360 Sep 15 10:00 ./
drwxrwxrwx  36 root   root      4096 Sep  4 10:57 ../
drwxr-xr-x   3 root   root      4096 Jul 27 14:39 chkrootkit/
drwxr-xr-x   4 root   root      4096 Apr 19 11:01 cpanel3-skel/
drwx------   2 root   root      4096 Jul 20 12:27 .cpanel-datastore/
drwx------   3 root   root      4096 Aug 10 18:29 .cpcpan/
drwx------   3 root   root      4096 Apr 19 07:12 .cpmysqlrpm/
drwx------   3 root   root      4096 Apr 19 22:55 .cpobjcache/
drwxr-xr-x   2 root   root     77824 Jul 11 09:21 down/
drwx------   2 root   root      4096 Apr 19 00:04 .gconfd/
drwx------   2 root   root      4096 Aug 10 18:36 .gnupg/
drwx------   8 root   root      4096 Apr 21 13:33 .MirrorSearch/
drwxr-xr-x   3 root   root      4096 May  3 19:06 mytop/
drwxr-xr-x   2 root   root      4096 Apr 19 07:22 public_ftp/
drwxr-xr-x   3 root   root      4096 Apr 19 07:22 public_html/
drwx------   2 root   root      4096 May 27 00:12 .spamassassin/
drwx------   2 root   root      4096 Apr 19 11:00 .ssh/
drwxr-xr-x   2 root   root      4096 May 26 14:22 .wapi/
drwxr-xr-x   2 root   root      4096 Aug  8 17:28 work/
 
  


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
ls to view directories only mikemrh9 Linux - Newbie 26 07-08-2015 01:27 PM
View directories size rickylim Linux - General 3 07-18-2006 11:24 PM
KDE Konqueror View Mode Icons (Image Preview/Tree View) sadarax Linux - General 7 06-27-2006 12:45 PM
How to view those .directories thort Linux - Newbie 3 02-12-2006 12:37 PM
How to view directories through putty of a server jai_linux Linux - Software 2 07-10-2004 02:04 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

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