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
df, grep, wild card itik AIX 2 01-24-2008 10:41 AM
Wild card in find perm braindrain Shell Programming and Scripting 1 04-12-2007 06:24 PM
How do I pass a wild card as an argument eja UNIX for Dummies Questions & Answers 2 03-28-2007 02:03 PM
ls and wild card - Should be simple! GNMIKE UNIX for Dummies Questions & Answers 2 10-13-2005 07:41 AM
using if with wild card patterns rooh UNIX for Dummies Questions & Answers 1 05-18-2002 07:15 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 03-19-2009
Raynon Raynon is offline
Registered User
  
 

Join Date: Sep 2006
Location: Sg
Posts: 350
Find Existence of File with wild card using Csh

Hi All,

I would like to find out the existence of files with wild card using CSH.
I have used the below code but does not seem to work.
Can any expert give me some advice ?


Code:
set nonomatch
set pattern = "_xxx"
set filetype =  ( *$pattern* ) 

if ( -e $filetype) then  
        echo "FILES with $pattern EXISTS"
else
        echo "FILES with $pattern DOES NOT EXISTS"
endif
  #2 (permalink)  
Old 03-20-2009
spirtle spirtle is offline
Registered User
  
 

Join Date: Jun 2008
Location: Scotland
Posts: 150
The problem is that the -e test expects just one file name, so it breaks if your pattern matches several files. Do the test on just one file, i.e. the first element of $filetype:
Code:
if ( -e $filetype[1] ) then
        echo "FILES with $pattern EXISTS"
else
        echo "FILES with $pattern DOES NOT EXISTS"
endif
  #3 (permalink)  
Old 03-26-2009
Raynon Raynon is offline
Registered User
  
 

Join Date: Sep 2006
Location: Sg
Posts: 350
Hi spirtle,

Thanks alot for the advice.
It's working fine now.
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:48 PM.


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