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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locating a directory

Status
Not open for further replies.

ianfo

Programmer
Aug 20, 2002
29
GB

If I have a directory,

/export/web/sun

Which contains lots of other directories of the following format....

explorer.hostid.hostname-2002.09.10.21.10

hostid is an unknown alphanumeric string and the date at the end of the directory name is also unknown...

I have an array containing only a list of hostnames.

What is the easiest way for me to then find the corresponding directory for that hostname (given that I only know the hostname and not the rest of the directory name such as the hostid or the date at the end)

Ideally I just want to be able to say

$hostdir=/export/web/sun/explorer.*.$hostname-*

But the easiest way i've found so far seems to be this

my $file="/export/web/sun/explorer.*${hostname}-*";

if (@showrev=glob "${file}") {

print @file;

}

Can anyone think of a simpler way of doing this?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top