The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Checking for existence of a flat file in UNIX ! Ariean Shell Programming and Scripting 4 04-25-2008 11:58 AM
checking for existence of table in oracle kjs SUN Solaris 0 10-19-2007 12:21 AM
Checking the existence of a file.. igandu Shell Programming and Scripting 7 06-13-2007 12:47 AM
File existence problem anormal UNIX for Dummies Questions & Answers 2 05-15-2006 09:54 AM
File existence mpang_ Shell Programming and Scripting 2 03-27-2006 08:27 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-24-2007
Registered User
 

Join Date: Dec 2006
Posts: 119
checking file existence

Hi,

My requirement was to check the existence of a file having a specified pattern.The way i tried to achieve this was

if [ -f ilvs_trace*.`date +'%m%d'` ]; then

echo "File found"
fi

an example file having this pattern was 'ilvs_trace01.0124'.

it will vary from 01-22,thats why i tried the above one using wildcard.

Would anyone can provide me a solution for this in the way i expects.

Your help is appreciated.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-24-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Do you want to display all the files with that specific pattern?
Then use for loop like this
Code:
for i in ilvs_trace*.`date +'%m%d'`
do
	echo $i
done
Reply With Quote
  #3 (permalink)  
Old 01-24-2007
becket's Avatar
Registered User
 

Join Date: Jul 2005
Location: Liege / Belgium
Posts: 36
if [ $line != $( echo $line |sed s/'ilvs_trace[0-2]\{0,2\}\.[0-9]\{0,4\}'/REGEXP/ ]
then
echo "File Found"
fi
Reply With Quote
  #4 (permalink)  
Old 01-24-2007
MizzGail's Avatar
Registered User
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 158
filelist=`ls directory| grep ilvs_trace`
for q in $filelist
do
echo "file found" $q
done
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0