ls command to list recursively ONLY subdirectories

Tags
beginners

 

 
Thread Tools Search this Thread
# 1  
Old 11-21-2005
Question ls command to list recursively ONLY subdirectories

Smilie
ls -dlRr
I've tried different combinations of the ls command using the above-mentioned options but none of them are giving me the output I am looking for.

Objective: To get a recursive listing of all subdirectories from a particular starting point. For example, if my starting point is directory A, and directory A contains subdirectories B, C, D, and each of the subdirectories contains a combination of directories and files called B1, C1, D1, etc., I want a recursive listing of the subdirectories contained, so the output will be something like
A
./B
./B1
./C1
etc. while excluding the list of the individual files.

I tried doing a search for 'ls' in the forum but didn't see anything within the first two pages of the results that the search pulled.

Help please!

Thanks!

- Hae

--- Edit ---

Nevermind! Found the answer at https://www.unix.com/showthread.php?t...t=ls+recursive

Last edited by HLee1981; 11-21-2005 at 06:08 PM..
# 2  
Old 11-21-2005
find /A -type d -ls
or
find /A -type d -ls |awk '{print $10}'
# 3  
Old 11-21-2005
Quote:
Originally Posted by RTM
find /A -type d -ls
or
find /A -type d -ls |awk '{print $10}'
RTM, neither of the commands worked using the find/A prefix. The result I get is find: cannot open /A: No such file or directory.

I tried it using a lowercase a after the /.

Thanks.
# 4  
Old 11-21-2005
what about

Code:
ls -Rl | grep "[a-z]:" | sed 's/://'

# 5  
Old 11-21-2005
Yea, sorry about that - you probably don't have a /A - but I was more using your example
Quote:
For example, if my starting point is directory A
# 6  
Old 05-14-2009
One line shell command to retrieve subdirectory names

Here is a brute force way to retrieve sub-directories in shell script:
ls -R | grep ":" | sed "s/://"
Any files named with a colon ":" will cause a false positive.
 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
UNIX command to display Owner,Group,Root and Subdirectories list vasuvv UNIX for Beginners Questions & Answers 6 03-20-2016 07:42 PM
How to list the names of the files from all the subdirectories? nuclearpenguin UNIX for Dummies Questions & Answers 2 10-18-2014 07:28 PM
List all files in subdirectories which are modifiled recently. balareddy UNIX for Advanced & Expert Users 3 11-01-2013 09:36 AM
List files with *.i extension in a directory and all its subdirectories + 30days old then remove lena keung Shell Programming and Scripting 2 01-11-2013 01:25 PM
How to recursively search for a list of keywords in a given directory? neelmani Shell Programming and Scripting 4 05-15-2012 11:48 AM
How to list all Subdirectories and files with its full path in a parent directory? johnveslin Shell Programming and Scripting 1 05-09-2012 11:25 PM
Remove files from subdirectories given a list of filenames yogeshkumkar Shell Programming and Scripting 15 03-15-2012 02:09 PM
How to search & list subdirectories with the given file name Siva SQL UNIX for Dummies Questions & Answers 0 10-28-2011 05:51 AM
Filter only gz files from list of subdirectories villain41 Shell Programming and Scripting 2 11-13-2009 06:28 AM
Recursively concatenate files in subdirectories with the same folder name joyce007 UNIX for Advanced & Expert Users 2 11-09-2009 12:41 PM
recursively concatenate files in subdirectories with same folder name joyce007 UNIX for Dummies Questions & Answers 2 11-05-2009 12:41 AM
Recursively go thorough subdirectories and checkout files shajiasalim Shell Programming and Scripting 3 08-13-2008 07:28 AM
get command to ftp subdirectories at once lydiaEd UNIX for Dummies Questions & Answers 3 12-07-2007 03:06 AM
list largest files in a directory & its subdirectories igidttam UNIX for Dummies Questions & Answers 6 09-25-2006 12:31 PM
List Files Recursively roberthawke UNIX for Dummies Questions & Answers 9 06-24-2002 07:19 PM