467,179 Members | 1,285 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,179 developers. It's quick & easy.

list the sub directories in a directory.

I managed to find thelist of files in a directory as below:

Expand|Select|Wrap|Line Numbers
  1. grep {/\.txt$/i}
How do I use grep statement to list directories of statting name as test...

Thanks and Regards
Jul 17 '08 #1
  • viewed: 1189
Share:
2 Replies
I managed to find thelist of files in a directory as below:

Expand|Select|Wrap|Line Numbers
  1. grep {/\.txt$/i}
How do I use grep statement to list directories of statting name as test...

Thanks and Regards
Expand|Select|Wrap|Line Numbers
  1. my @dirs = grep { chomp; /^\.\/test/i } `find . -type d -maxdepth 1 -iname "*"`;
Assuming u r working on unix/linux, above code can be used to store directory names (into @dirs) that start with 'test'. If you want to find directories recursively remove '-maxdepth 1' from the find command...

regs,
Jul 17 '08 #2
numberwhun
Expert Mod 2GB
Please refrain from including your signature in your posts. It is not allowed per the Posting Guidelines of this site.

Regards,

Moderator
Jul 17 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by david | last post: by
14 posts views Thread by kpp9c | last post: by
4 posts views Thread by thoseion@gmail.com | last post: by
3 posts views Thread by rn5a@rediffmail.com | last post: by
3 posts views Thread by Al Moodie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.