The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
check if remote file exists hcclnoodles Shell Programming and Scripting 2 08-27-2008 05:53 PM
How to check if a direcorty exists? SunnyK Shell Programming and Scripting 2 11-08-2007 10:47 AM
How can I check if directory exists in a makefile zivsegal UNIX for Dummies Questions & Answers 2 09-10-2007 03:12 AM
check if directory exists jerardfjay Shell Programming and Scripting 2 06-13-2005 02:26 PM
perl ftp check file exists methos Shell Programming and Scripting 2 06-18-2003 08:21 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-30-2007
philplasma's Avatar
philplasma philplasma is offline
Registered User
  
 

Join Date: May 2007
Location: Quebec
Posts: 18
how to check if masked directory exists?

I'm trying to write a script that identifies whether a directory of the form AWL.????????.IP exists. I have one that exists which is AWL.05301032.IP.

When I test like this: If [[ -d AWL.05301032.IP ]]

I get true, but when I test like this:
If [[ -d AWL.????????.IP ]]
Or like this
If [[ -d AWL.*.IP ]]
Or any other variation of wild cards, I get false.

Is there a way for me to check for the presence of a directory that uses a mask?

Thanks for any help that can be provided!

Phil Plasma
  #2 (permalink)  
Old 05-30-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
The problem is your wild cards are expanding into multiple items.

Try something like the following

Code:
for d in AWL.????????.IP 
do
     if test -d $d
     then
           echo $d exists
     fi
done
  #3 (permalink)  
Old 05-30-2007
philplasma's Avatar
philplasma philplasma is offline
Registered User
  
 

Join Date: May 2007
Location: Quebec
Posts: 18
Thanks for the quick reply, Porter, but it didn't work. First I ran it as is and got nothing, then I modified it as such:

Code:
for d in AWL.????????.IP 
do
     echo $d
     if test -d $d
     then
           echo $d exists
     fi
done
And what printed to the screen was

Code:
AWL.????????.IP
This is a ksh on a windows server using MKS Toolkit.
  #4 (permalink)  
Old 05-30-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
If you get back "AWP.????????.IP" then nothing matched the expression.

The way general expressions work in the shell is if there are file matches those that match are returned, else the expression.

Can you do "ls -l" for us to see what you are seeing?

It might be a case sensitivity type thing, note, windows file systems are case-insensitive, UNIX ones are normally case-sensitive.

You might need to try "awp.????????.ip" or some variation.
  #5 (permalink)  
Old 05-30-2007
philplasma's Avatar
philplasma philplasma is offline
Registered User
  
 

Join Date: May 2007
Location: Quebec
Posts: 18
Unhappy

thanks so much, it works now. It even worked before only I had made the mistake of looking for AWL.*.IP which is the standard for all of my other customers, but for this customer the directories are called TL.*.IP, so your first reply as to how to fix this succeeded.

Sorry about the extra reply I had to draw from you.

Thanks again!

Phil Plasma
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0