[PLUG] listing directories only
Carla Schroder
carla at bratgrrl.com
Thu Dec 7 01:18:21 UTC 2006
Here's an odd one for the wise old geekbeards. I can't seem to find an easy
way to list directories only. man ls says:
-d, --directory
list directory entries instead of contents, and do not dereference symbolic
links
But ls -d does not work:
$ ls -d
.
$ ls -d /home/carla
/home/carla
Good ole find does the job:
$ find ~ -maxdepth 1 -type d
/home/carla
/home/carla/.kde
/home/carla/.qt
/home/carla/Desktop
/home/carla/.local
[...]
ls will list subdirectories and their contents:
$ ls -R
.:
./downloads:
asterisk-1.4.0-beta3 asterisk-1.4.0-beta3.tar.gz AstLinux-0.4.4.iso
debian-testing-i386-netinst.iso loop
./downloads/asterisk-1.4.0-beta3/agi:
agi-test.agi DialAnMp3.agi eagi-sphinx-test.c eagi-test.c fastagi-test
jukebox.agi Makefile numeralize
[...]
The tree command is easy and fun:
$ tree -d -L 1
.
|-- 1writing
|-- Desktop
|-- Examples -> /usr/share/example-content
|-- booksnmusic
|-- correspondence
|-- downloads
|-- finances
|-- howto
|-- pictures
|-- sda
`-- webs
So.... does anyone know why ls cannot do this?
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Carla Schroder
Linux geek and random computer tamer
check out my Linux Cookbook!
http://www.oreilly.com/catalog/linuxckbk/
best book for sysadmins and power users
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
More information about the PLUG
mailing list