Gentoo Forums
Gentoo Forums
Quick Search: in
ls --list only directorys (solved)
View unanswered posts
View posts from last 24 hours

rackathon
Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Off the Wall
View previous topic :: View next topic  
Author Message
turtles
l33t
l33t


Joined: 31 Dec 2004
Posts: 739
Location: (44.057116, -123.103394)

PostPosted: Thu Dec 06, 2007 1:17 pm    Post subject: ls --list only directorys (solved) Reply with quote

If one has a directory with 1000's of files and I just want to see other directorys not any of the 1000's of files is there an switch for this in ls? BTW I read man ls.
_________________
Forums user names explained


Last edited by turtles on Fri Dec 07, 2007 10:57 am; edited 1 time in total
Back to top
View user's profile Send private message
timeBandit
Moderator
Moderator


Joined: 30 Dec 2004
Posts: 2115
Location: here, there or in transit

PostPosted: Thu Dec 06, 2007 1:20 pm    Post subject: Reply with quote

Code:
find . -maxdepth 1 -type d

_________________
Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.
Back to top
View user's profile Send private message
nixnut
Administrator
Administrator


Joined: 09 Apr 2004
Posts: 10459
Location: the dutch mountains

PostPosted: Thu Dec 06, 2007 1:27 pm    Post subject: Reply with quote

Moved from Portage & Programming to Off the Wall.
Not about gentoo, so moved here.

list directories in current dir: ls -d */
list directories in /etc/: ls -d /etc/*/
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered

talk is cheap. supply exceeds demand
Back to top
View user's profile Send private message
yabbadabbadont
Veteran
Veteran


Joined: 13 Mar 2003
Posts: 4739

PostPosted: Thu Dec 06, 2007 2:34 pm    Post subject: Reply with quote

nixnut wrote:
Moved from Portage & Programming to Off the Wall.
Not about gentoo, so moved here.

list directories in current dir: ls -d */
list directories in /etc/: ls -d /etc/*/

The previously listed find command will list both hidden, and visible, directories. Your command will only list the non-hidden ones. Just an FYI to the OP. :D
Back to top
View user's profile Send private message
nixnut
Administrator
Administrator


Joined: 09 Apr 2004
Posts: 10459
Location: the dutch mountains

PostPosted: Thu Dec 06, 2007 2:39 pm    Post subject: Reply with quote

fine. so we ask for both:
ls -d .*/ */
:wink:
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered

talk is cheap. supply exceeds demand
Back to top
View user's profile Send private message
yabbadabbadont
Veteran
Veteran


Joined: 13 Mar 2003
Posts: 4739

PostPosted: Thu Dec 06, 2007 2:54 pm    Post subject: Reply with quote

nixnut wrote:
fine. so we ask for both:
ls -d .*/ */
:wink:

:lol:

OK, now make it show only directories recursively... ;)

(In case you couldn't tell, I'm a big fan of the find command :D)
Back to top
View user's profile Send private message
nixnut
Administrator
Administrator


Joined: 09 Apr 2004
Posts: 10459
Location: the dutch mountains

PostPosted: Thu Dec 06, 2007 3:02 pm    Post subject: Reply with quote

yabbadabbadont wrote:
nixnut wrote:
fine. so we ask for both:
ls -d .*/ */
:wink:

:lol:

OK, now make it show only directories recursively... ;)

(In case you couldn't tell, I'm a big fan of the find command :D)

tree -ad :P
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered

talk is cheap. supply exceeds demand
Back to top
View user's profile Send private message
yabbadabbadont
Veteran
Veteran


Joined: 13 Mar 2003
Posts: 4739

PostPosted: Thu Dec 06, 2007 3:32 pm    Post subject: Reply with quote

nixnut wrote:
tree -ad :P

Code:
/home/daffy $ tree
bash: tree: command not found


find is installed by default... so there. :P :D
Back to top
View user's profile Send private message
nixnut
Administrator
Administrator


Joined: 09 Apr 2004
Posts: 10459
Location: the dutch mountains

PostPosted: Thu Dec 06, 2007 3:35 pm    Post subject: Reply with quote

yabbadabbadont wrote:
nixnut wrote:
tree -ad :P

Code:
/home/daffy $ tree
bash: tree: command not found


find is installed by default... so there. :P :D

/me points at yabbadabbadont and laughs for not having tree :P
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered

talk is cheap. supply exceeds demand
Back to top
View user's profile Send private message
madchaz
l33t
l33t


Joined: 01 Jul 2003
Posts: 823
Location: Quebec, Cadada

PostPosted: Thu Dec 06, 2007 3:40 pm    Post subject: Reply with quote

Another alternative

ls -la | grep dr

not as effective, but hey. Almost warants a rtfm ;-)
_________________
(\ /)
(O.o)
(> <)
Copy bunny, help him take over world. NOW!
Back to top
View user's profile Send private message
yabbadabbadont
Veteran
Veteran


Joined: 13 Mar 2003
Posts: 4739

PostPosted: Thu Dec 06, 2007 3:43 pm    Post subject: Reply with quote

nixnut wrote:
/me points at yabbadabbadont and laughs for not having tree :P

/me wonders if "tree" is a euphemism for "wood"

/me then runs away from ban kitty :D
Back to top
View user's profile Send private message
old school
Apprentice
Apprentice


Joined: 20 Nov 2004
Posts: 194
Location: The Covered Bridge Capital of Oregon

PostPosted: Thu Dec 06, 2007 3:46 pm    Post subject: Reply with quote

yabbadabbadont wrote:
nixnut wrote:
/me points at yabbadabbadont and laughs for not having tree :P

/me wonders if "tree" is a euphemism for "wood"

/me then runs away from ban kitty :D
:lol: :lol: :lol: You can run, but you can't hide from the ban kitty. :wink:
_________________
Joey, do you like movies about gladiators?
Back to top
View user's profile Send private message
nixnut
Administrator
Administrator


Joined: 09 Apr 2004
Posts: 10459
Location: the dutch mountains

PostPosted: Thu Dec 06, 2007 3:56 pm    Post subject: Reply with quote

madchaz wrote:
Another alternative

ls -la | grep dr

not as effective, but hey. Almost warants a rtfm ;-)

except that would also list any files containing the string 'dr' and any files owned by a group or user containing the string 'dr'
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered

talk is cheap. supply exceeds demand
Back to top
View user's profile Send private message
durian
Apprentice
Apprentice


Joined: 16 Jul 2003
Posts: 216
Location: :noitacoL

PostPosted: Thu Dec 06, 2007 4:06 pm    Post subject: Reply with quote

nixnut wrote:
madchaz wrote:
Another alternative

ls -la | grep dr

not as effective, but hey. Almost warants a rtfm ;-)

except that would also list any files containing the string 'dr' and any files owned by a group or user containing the string 'dr'


make it ls -la | grep ^dr so it only matches in the beginning of the line.

-peter
Back to top
View user's profile Send private message
timeBandit
Moderator
Moderator


Joined: 30 Dec 2004
Posts: 2115
Location: here, there or in transit

PostPosted: Thu Dec 06, 2007 4:54 pm    Post subject: Reply with quote

old school wrote:
yabbadabbadont wrote:
/me then runs away from ban kitty :D
:lol: :lol: :lol: You can run, but you can't hide from the ban kitty. :wink:
Proof:
$ touch bankitty # (probably bad idea)
$ find bankitty
bankitty
$ who < bankitty
timeBandit tty0         Dec  6 11:51 (:0.0)
$ who > bankitty
Try it yourself and see: ban kitty beats all. :D
_________________
Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.
Back to top
View user's profile Send private message
turtles
l33t
l33t


Joined: 31 Dec 2004
Posts: 739
Location: (44.057116, -123.103394)

PostPosted: Fri Dec 07, 2007 10:56 am    Post subject: Reply with quote

Thanks all!
This is why I love Gentoo.
Code:
ls -d */

Is exactly what I was looking for and the least amount of typing.

And
Code:
ls -d .*/ */
Is a handy bonus.[/code]
_________________
Forums user names explained
Back to top
View user's profile Send private message
rokstar83
Guru
Guru


Joined: 09 Apr 2005
Posts: 422
Location: Not Funny Anymore, Maryland, USA

PostPosted: Fri Dec 07, 2007 11:27 am    Post subject: Reply with quote

turtles wrote:
Thanks all!
This is why I love Gentoo.
Code:
ls -d */

Is exactly what I was looking for and the least amount of typing.

And
Code:
ls -d .*/ */
Is a handy bonus.[/code]


Speaking of saving typing, I've always found that ls is one of my favorite unix commands to make alias out of.

Code:
alias lsd="ls -d"


Dunno if thats helpful or at all relevent but there it is.
Back to top
View user's profile Send private message
Zepp
Veteran
Veteran


Joined: 15 Mar 2004
Posts: 1241
Location: Ontario, Canada

PostPosted: Fri Dec 07, 2007 12:31 pm    Post subject: Reply with quote

rokstar83 wrote:
turtles wrote:
Thanks all!
This is why I love Gentoo.
Code:
ls -d */

Is exactly what I was looking for and the least amount of typing.

And
Code:
ls -d .*/ */
Is a handy bonus.[/code]


Speaking of saving typing, I've always found that ls is one of my favorite unix commands to make alias out of.

Code:
alias lsd="ls -d"


Dunno if thats helpful or at all relevent but there it is.



lsd is bad mmmkay.
Back to top
View user's profile Send private message
yabbadabbadont
Veteran
Veteran


Joined: 13 Mar 2003
Posts: 4739

PostPosted: Fri Dec 07, 2007 3:52 pm    Post subject: Reply with quote

Zepp wrote:
lsd is bad mmmkay.

Great... just great. Now I have to clean my beverage off of my keyboard. :lol:
Back to top
View user's profile Send private message
Dralnu
Veteran
Veteran


Joined: 24 May 2006
Posts: 1919

PostPosted: Fri Dec 07, 2007 7:33 pm    Post subject: Reply with quote

Zepp wrote:
lsd is bad mmmkay.


Is it bad that I was thinking the same thing?
_________________
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
Back to top
View user's profile Send private message
Dralnu
Veteran
Veteran


Joined: 24 May 2006
Posts: 1919

PostPosted: Fri Dec 07, 2007 8:01 pm    Post subject: Reply with quote

yabbadabbadont wrote:
Zepp wrote:
lsd is bad mmmkay.

Great... just great. Now I have to clean my beverage off of my keyboard. :lol:


Ants should work!
_________________
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
Back to top
View user's profile Send private message
turtles
l33t
l33t


Joined: 31 Dec 2004
Posts: 739
Location: (44.057116, -123.103394)

PostPosted: Sat Dec 08, 2007 12:20 pm    Post subject: Reply with quote

Dralnu wrote:
yabbadabbadont wrote:
Zepp wrote:
lsd is bad mmmkay.

Great... just great. Now I have to clean my beverage off of my keyboard. :lol:


Ants should work!


Code:
alias lsd="ls -d */"

Code:
alias ant="cd .. && ls -d */"

thanks rokstar83 for alias.
Just dont get carried away by ants wile using lsd unless you have an alias.
_________________
Forums user names explained
Back to top
View user's profile Send private message
kreedcarmoch
n00b
n00b


Joined: 09 Apr 2005
Posts: 51
Location: San Antonio, Texas

PostPosted: Sat Dec 08, 2007 10:22 pm    Post subject: Reply with quote

yabbadabbadont wrote:
nixnut wrote:
fine. so we ask for both:
ls -d .*/ */
:wink:

:lol:

OK, now make it show only directories recursively... ;)

(In case you couldn't tell, I'm a big fan of the find command :D)

setopt dotglob
ls -d **/*/

Only works in zsh though (bash doesn't support dotglobbing with a recursive glob AFAIK).
Back to top
View user's profile Send private message
denstark
l33t
l33t


Joined: 02 Jun 2003
Posts: 654
Location: bos.ma.us

PostPosted: Sat Dec 08, 2007 10:54 pm    Post subject: Reply with quote

Only in linux would there be 64 ways to list only the directories.
_________________
Blog
Code:
rokstar> I mean come on, you might as well have said "sorry we were too busy blowing dead goats to even bother to give an error message for this test case"
Back to top
View user's profile Send private message
Zepp
Veteran
Veteran


Joined: 15 Mar 2004
Posts: 1241
Location: Ontario, Canada

PostPosted: Sat Dec 08, 2007 10:59 pm    Post subject: Reply with quote

denstark wrote:
Only in linux would there be 64 ways to list only the directories.
:lol:
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Off the Wall All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum