The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
list the files but exclude the files in subdirectories shyjuezy UNIX for Dummies Questions & Answers 8 10-15-2008 02:42 PM
get command to ftp subdirectories at once lydiaEd UNIX for Dummies Questions & Answers 3 12-07-2007 03:06 AM
FTP command to search recursively in windows folder lakshmis10 Shell Programming and Scripting 6 10-18-2007 06:09 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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-21-2005
HLee1981 HLee1981 is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 35
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 Recursive directory listing without listing files

Last edited by HLee1981; 11-21-2005 at 06:08 PM..
  #2 (permalink)  
Old 11-21-2005
RTM's Avatar
RTM RTM is offline Forum Advisor  
Hog Hunter
  
 

Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
find /A -type d -ls
or
find /A -type d -ls |awk '{print $10}'
  #3 (permalink)  
Old 11-21-2005
HLee1981 HLee1981 is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 35
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 (permalink)  
Old 11-21-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
what about


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

  #5 (permalink)  
Old 11-21-2005
RTM's Avatar
RTM RTM is offline Forum Advisor  
Hog Hunter
  
 

Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
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 (permalink)  
Old 05-14-2009
drodecker drodecker is offline
Registered User
  
 

Join Date: May 2009
Posts: 1
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0