Link to home
Start Free TrialLog in
Avatar of gravindra1977
gravindra1977

asked on

How do I find if a specific directory exists in a filesystem using perl

Hi,
I have a problem where I was asked to find if a particular directory exists in a filesystem. For example we have SunOS unix operating system which has /uXX filesystems. I need a perl script which would determine which all filesystems contain a directory called 'odsap1'.
Could anyone please provide with a perl script which would search all the filesystems and determine which all would contain this directory called, 'odsap1'.
Thanks in advance. Your help is really appreciated
Avatar of Suhas .
Suhas .
Flag of United States of America image

File::Find module can help you to get the solution...

http://search.cpan.org/~rgarcia/perl-5.10.0/lib/File/Find.pm 
ASKER CERTIFIED SOLUTION
Avatar of Adam314
Adam314

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tintin
Tintin

Do you really want to use Perl for such a simple task?  Just type in

find / -type d -name odsap1
$dir = "/bla/bla";
if (-d $dir) {
  print "$dir exist\n";
}