| View previous topic :: View next topic |
| Author |
Message |
turtles Veteran


Joined: 31 Dec 2004 Posts: 1026 Location: (44.057116, -123.103394)
|
Posted: Thu Dec 06, 2007 6:17 pm Post subject: ls --list only directorys (solved) |
|
|
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. _________________ Do you still use Perl?
Last edited by turtles on Fri Dec 07, 2007 3:57 pm; edited 1 time in total |
|
| Back to top |
|
 |
timeBandit Administrator


Joined: 31 Dec 2004 Posts: 2667 Location: here, there or in transit
|
Posted: Thu Dec 06, 2007 6:20 pm Post subject: |
|
|
| 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 |
|
 |
nixnut Administrator


Joined: 09 Apr 2004 Posts: 10951 Location: the dutch mountains
|
Posted: Thu Dec 06, 2007 6:27 pm Post subject: |
|
|
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 |
|
 |
yabbadabbadont Advocate


Joined: 14 Mar 2003 Posts: 4790 Location: 2 exits past crazy
|
Posted: Thu Dec 06, 2007 7:34 pm Post subject: |
|
|
| 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.  |
|
| Back to top |
|
 |
nixnut Administrator


Joined: 09 Apr 2004 Posts: 10951 Location: the dutch mountains
|
Posted: Thu Dec 06, 2007 7:39 pm Post subject: |
|
|
fine. so we ask for both:
ls -d .*/ */
 _________________ 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 |
|
 |
yabbadabbadont Advocate


Joined: 14 Mar 2003 Posts: 4790 Location: 2 exits past crazy
|
Posted: Thu Dec 06, 2007 7:54 pm Post subject: |
|
|
| nixnut wrote: | fine. so we ask for both:
ls -d .*/ */
 |
OK, now make it show only directories recursively...
(In case you couldn't tell, I'm a big fan of the find command ) |
|
| Back to top |
|
 |
nixnut Administrator


Joined: 09 Apr 2004 Posts: 10951 Location: the dutch mountains
|
Posted: Thu Dec 06, 2007 8:02 pm Post subject: |
|
|
| yabbadabbadont wrote: | | nixnut wrote: | fine. so we ask for both:
ls -d .*/ */
 |
OK, now make it show only directories recursively...
(In case you couldn't tell, I'm a big fan of the find command ) |
tree -ad  _________________ 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 |
|
 |
yabbadabbadont Advocate


Joined: 14 Mar 2003 Posts: 4790 Location: 2 exits past crazy
|
Posted: Thu Dec 06, 2007 8:32 pm Post subject: |
|
|
| nixnut wrote: | tree -ad  |
| Code: | /home/daffy $ tree
bash: tree: command not found |
find is installed by default... so there.  |
|
| Back to top |
|
 |
nixnut Administrator


Joined: 09 Apr 2004 Posts: 10951 Location: the dutch mountains
|
Posted: Thu Dec 06, 2007 8:35 pm Post subject: |
|
|
| yabbadabbadont wrote: | | nixnut wrote: | tree -ad  |
| Code: | /home/daffy $ tree
bash: tree: command not found |
find is installed by default... so there.  |
/me points at yabbadabbadont and laughs for not having tree  _________________ 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 |
|
 |
madchaz l33t


Joined: 01 Jul 2003 Posts: 955 Location: Quebec, Canada
|
Posted: Thu Dec 06, 2007 8:40 pm Post subject: |
|
|
Another alternative
ls -la | grep dr
not as effective, but hey. Almost warants a rtfm  _________________ Someone asked me once if I suffered from mental illness. I told him I enjoyed every second of it.
www.madchaz.com my "not so simple" home system. Not always online. Web Server is noisy. |
|
| Back to top |
|
 |
yabbadabbadont Advocate


Joined: 14 Mar 2003 Posts: 4790 Location: 2 exits past crazy
|
Posted: Thu Dec 06, 2007 8:43 pm Post subject: |
|
|
| nixnut wrote: | /me points at yabbadabbadont and laughs for not having tree  |
/me wonders if "tree" is a euphemism for "wood"
/me then runs away from ban kitty  |
|
| Back to top |
|
 |
Old School Apprentice


Joined: 20 Nov 2004 Posts: 230 Location: The Covered Bridge Capital of Oregon
|
Posted: Thu Dec 06, 2007 8:46 pm Post subject: |
|
|
| yabbadabbadont wrote: | | nixnut wrote: | /me points at yabbadabbadont and laughs for not having tree  |
/me wonders if "tree" is a euphemism for "wood"
/me then runs away from ban kitty  | You can run, but you can't hide from the ban kitty.  _________________ I am not young enough to know everything.
- Oscar Wilde |
|
| Back to top |
|
 |
nixnut Administrator


Joined: 09 Apr 2004 Posts: 10951 Location: the dutch mountains
|
Posted: Thu Dec 06, 2007 8:56 pm Post subject: |
|
|
| 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 |
|
 |
durian Guru


Joined: 16 Jul 2003 Posts: 312 Location: Margretetorp
|
Posted: Thu Dec 06, 2007 9:06 pm Post subject: |
|
|
| 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 |
|
 |
timeBandit Administrator


Joined: 31 Dec 2004 Posts: 2667 Location: here, there or in transit
|
Posted: Thu Dec 06, 2007 9:54 pm Post subject: |
|
|
| old school wrote: | | yabbadabbadont wrote: | /me then runs away from ban kitty  | You can run, but you can't hide from the ban kitty.  |
| 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.  _________________ 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 |
|
 |
turtles Veteran


Joined: 31 Dec 2004 Posts: 1026 Location: (44.057116, -123.103394)
|
Posted: Fri Dec 07, 2007 3:56 pm Post subject: |
|
|
Thanks all!
This is why I love Gentoo.
Is exactly what I was looking for and the least amount of typing.
And
Is a handy bonus.[/code] _________________ Do you still use Perl? |
|
| Back to top |
|
 |
rokstar83 Guru


Joined: 09 Apr 2005 Posts: 422 Location: MD
|
Posted: Fri Dec 07, 2007 4:27 pm Post subject: |
|
|
| turtles wrote: | Thanks all!
This is why I love Gentoo.
Is exactly what I was looking for and the least amount of typing.
And
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.
Dunno if thats helpful or at all relevent but there it is. |
|
| Back to top |
|
 |
Zepp Veteran


Joined: 15 Mar 2004 Posts: 1246 Location: Ontario, Canada
|
Posted: Fri Dec 07, 2007 5:31 pm Post subject: |
|
|
| rokstar83 wrote: | | turtles wrote: | Thanks all!
This is why I love Gentoo.
Is exactly what I was looking for and the least amount of typing.
And
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.
Dunno if thats helpful or at all relevent but there it is. |
lsd is bad mmmkay. |
|
| Back to top |
|
 |
yabbadabbadont Advocate


Joined: 14 Mar 2003 Posts: 4790 Location: 2 exits past crazy
|
Posted: Fri Dec 07, 2007 8:52 pm Post subject: |
|
|
| Zepp wrote: | | lsd is bad mmmkay. |
Great... just great. Now I have to clean my beverage off of my keyboard.  |
|
| Back to top |
|
 |
Dralnu Veteran


Joined: 24 May 2006 Posts: 1919
|
Posted: Sat Dec 08, 2007 12:33 am Post subject: |
|
|
| 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 |
|
 |
Dralnu Veteran


Joined: 24 May 2006 Posts: 1919
|
Posted: Sat Dec 08, 2007 1:01 am Post subject: |
|
|
| yabbadabbadont wrote: | | Zepp wrote: | | lsd is bad mmmkay. |
Great... just great. Now I have to clean my beverage off of my keyboard.  |
Ants should work! _________________ The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner. |
|
| Back to top |
|
 |
turtles Veteran


Joined: 31 Dec 2004 Posts: 1026 Location: (44.057116, -123.103394)
|
Posted: Sat Dec 08, 2007 5:20 pm Post subject: |
|
|
| Dralnu wrote: | | yabbadabbadont wrote: | | Zepp wrote: | | lsd is bad mmmkay. |
Great... just great. Now I have to clean my beverage off of my keyboard.  |
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. _________________ Do you still use Perl? |
|
| Back to top |
|
 |
kreedcarmoch n00b

Joined: 09 Apr 2005 Posts: 51 Location: San Antonio, Texas
|
Posted: Sun Dec 09, 2007 3:22 am Post subject: |
|
|
| yabbadabbadont wrote: | | nixnut wrote: | fine. so we ask for both:
ls -d .*/ */
 |
OK, now make it show only directories recursively...
(In case you couldn't tell, I'm a big fan of the find command ) |
setopt dotglob
ls -d **/*/
Only works in zsh though (bash doesn't support dotglobbing with a recursive glob AFAIK). |
|
| Back to top |
|
 |
denstark l33t


Joined: 02 Jun 2003 Posts: 654 Location: sd.ca.us
|
Posted: Sun Dec 09, 2007 3:54 am Post subject: |
|
|
Only in linux would there be 64 ways to list only the directories. _________________ Blog
| Code: | denstark> starbuck authorizes torture?
rokstar> sure they do, you tried their coffee?
|
|
|
| Back to top |
|
 |
Zepp Veteran


Joined: 15 Mar 2004 Posts: 1246 Location: Ontario, Canada
|
Posted: Sun Dec 09, 2007 3:59 am Post subject: |
|
|
| denstark wrote: | | Only in linux would there be 64 ways to list only the directories. |  |
|
| Back to top |
|
 |
|