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 OF DIRECTORIES AND SUBDIRECTORIES

Status
Not open for further replies.

conquersmile

Technical User
Aug 29, 2003
20
AU
Hi,

How do I get the list of directories and subdirectories present in a particular path .

ls -R displays the file names also, but i want only the directories and subdirectories names.

Thanks and Regards,
Padma Swamy
 
You should find this question from the forum first. Anyway, the most simply way is

find .

tikual
 
Hi,

I thought there is some option in ls apart from the find command.

Thanks for the help

Regards,
Padma Swamy
 
Not fully correct of my post before. There should be

find /pathname -type d

tikual
 
Try ls -d
d, -lists directory entries instead of contents

you can also try the command test and check if a directory exists.
 
Hi,

I tried the ls -d command but it is displaying only one "." (dot) as the output.

Thanks and Regards,
Padma Swamy
 
Try this to get just the full path of the directories and subdirectories from root: find / -type d -print

Also, ls -lR | grep ^d will give you a long listing (including owner, size, timestamp) of directories and subdirectories, but not the path to the subdirectories.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top