Home Man
Search
Today's Posts
Register

This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in the UNIX for Beginners Questions & Answers forum.

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


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 05: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.
 

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
UNIX command to display Owner,Group,Root and Subdirectories list vasuvv UNIX for Beginners Questions & Answers 6 03-20-2016 06:42 PM
How to list the names of the files from all the subdirectories? nuclearpenguin UNIX for Dummies Questions & Answers 2 10-18-2014 06:28 PM
How to recursively search for a list of keywords in a given directory? neelmani Shell Programming and Scripting 4 05-15-2012 10:48 AM
How to search & list subdirectories with the given file name Siva SQL UNIX for Dummies Questions & Answers 0 10-28-2011 04:51 AM
How to list all files in dir and sub-dir's recursively along with file size? nmakkena UNIX for Dummies Questions & Answers 3 10-28-2010 08:23 AM
Filter only gz files from list of subdirectories villain41 Shell Programming and Scripting 2 11-13-2009 05:28 AM
Recursively concatenate files in subdirectories with the same folder name joyce007 UNIX for Advanced & Expert Users 2 11-09-2009 11:41 AM
recursively concatenate files in subdirectories with same folder name joyce007 UNIX for Dummies Questions & Answers 2 11-04-2009 11:41 PM
Recursively go thorough subdirectories and checkout files shajiasalim Shell Programming and Scripting 3 08-13-2008 06:28 AM
List Files Recursively roberthawke UNIX for Dummies Questions & Answers 9 06-24-2002 06:19 PM


All times are GMT -4. The time now is 01:12 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password