Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding directories or files

Status
Not open for further replies.

user2base

Technical User
Oct 16, 2002
29
0
0
GB
How to implement a script that returns all the files and directories (including the path) which name contains "$txt" from "$srcdir" ??
I am close to it using the File::Find module but not quite...

Thanks for your help.
 
ok.
So far I am using:

find sub { print "$File::Find::name\n" if -e "$txt"}, "$src";

but the output is not what I expect as it returns all the directories that are contained in the same parent directory that the one I search for...
 
Try using a regex match instead. This will print any file or directory that contains the text in the $txt variable. You will have to modify it some if you want to match exactly.
Code:
find sub { print "$File::Find::name\n" if /$txt/ }, "$src";
jaa
 
or, on a Unix or Linux box,
Code:
@files = `find $srcdir -name "*$txt*" -print`;
'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top