suppose in my current directory, I have 50 sub-directories. Now, I am interested only in about 20 of those sub-directories (whose names match a pattern). I would like to recursively list the contents of these 20 sub-directories. How do I do that ?

I would like to do this in Solaris 10 and Linux(RHEL 5.x).

thank you,

link|improve this question

62% accept rate
feedback

3 Answers

You can use ls and find to accomplish this. Simply use find to get the directories and pass those into ls:

ls `find -type d -name my_dir`

If you need more verbose output, you can also use ls's options:

ls `find -type d -name my_dir` -al
link|improve this answer
If I remember correctly, Solaris is a BSD variant, so find will need the -print option. – pavium Jul 22 '11 at 14:37
You are probably correct. I haven't used Solaris in a long time. – sbtkd85 Jul 22 '11 at 15:37
feedback

Use tree. Just navigate to the directory you want to get the structure for, and type tree. For more see here. Use the -l and -r switches.

link|improve this answer
feedback

ls -R pattern, if you can express pattern as a shell glob.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.