ls command to list recursively ONLY subdirectories

:confused:
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 Recursive directory listing without listing files

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.

what about

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

Yea, sorry about that - you probably don't have a /A - but I was more using your example

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.