![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Determine string in Perl. | ejdv | Shell Programming and Scripting | 4 | 05-14-2008 04:34 AM |
| How Can I Easily Determine If A File Has been Added to a Directory | goodmis | UNIX for Advanced & Expert Users | 7 | 02-04-2007 01:13 AM |
| How Can I Easily Determine If A File Has been Added to a Directory | goodmis | UNIX for Dummies Questions & Answers | 1 | 01-31-2007 06:56 PM |
| cannot determine current directory | axes | UNIX for Advanced & Expert Users | 15 | 11-13-2006 07:39 AM |
| determine owner directory permissions from within the directory | Sniper Pixie | Shell Programming and Scripting | 4 | 03-07-2006 05:06 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
[Perl] Determine directory name
Hi there,
I wonder if it is possible the determine a name of a directory which is different on various hosts. Let me try to explain. I have the directory /tmp/dir1/dir2/canchangedir. This directory name is different on various hosts. I need to use the directory name, independent from the host I am on. This is the directory structure on all hosts (example): /tmp/dir1 /tmp/dir1/dir2 /tmp/dir1/dir2/canchangedir /tmp/dir1/dir2/canchangedir/dir3 /tmp/dir1/dir2/file1 /tmp/dir1/dir2/file2 /tmp/dir1/dir2/file3 The name "canchangedir" is different on all hosts. The structure is the same and the dir1 and dir2 name too. I tried with find and basename, but did not succeed. Anyone out there that can do the magic ?? Thanks, E.J. |
|
||||
|
@KevinADC,
Okay, a bit short (open it ? search it ? search what ?) , but I think I got it. Code:
@dir2_contents = </tmp/dir1/dir2/*>;
foreach $item (@dir2_contents) {
if ( -d $item ) {
$needed_dir = basename($item);
}
}
printf "needed_dir = $needed_dir\n";
|
| Sponsored Links | ||
|
|