Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

list directory names

Status
Not open for further replies.

kasparov

Programmer
Feb 13, 2002
203
GB
I want to list the directory names in my directory. There must be a better way than these:

ls -l | grep ^d | awk '{ print $9 }'

or

ls -F | grep / | sed 's/\///'

Is there?

Thanks, Chris

 
man find vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
You can simply say find ~ or find . if you are already in the directory...

This will list all files in the given directory. I don't know, however, which method is more efficient...


 
I tried find but the output still needs editing, eg:

find . -type d -print

gives me the directory '.' and puts './' at the beginning of each line.

Not to worry - I think ls -F | sed 's/\///' is probably the best.

Thanks anyway, Chris
 
Thanks dcoulette - goes to show I should RTFM after all.
 
If you just want to 'see' the directories from an input shell prompt:
Code:
ls -d */.
will give you the name of all directories but with '/.' appended.
I use it because it is faster to enter at a prompt than the other versions given above. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top