By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,903 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,903 IT Pros & Developers. It's quick & easy.

list the sub directories in a directory.

P: 89
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
Share this Question
Share on Google+
2 Replies


P: 2
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 2.5K+
P: 3,503
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.