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
Checking for existence of a flat file in UNIX ! Ariean Shell Programming and Scripting 4 04-25-2008 02:58 PM
checking for existence of table in oracle kjs SUN Solaris 0 10-19-2007 03:21 AM
Checking the existence of a file.. igandu Shell Programming and Scripting 7 06-13-2007 03:47 AM
File existence problem anormal UNIX for Dummies Questions & Answers 2 05-15-2006 12:54 PM
File existence mpang_ Shell Programming and Scripting 2 03-27-2006 11:27 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-24-2007
DILEEP410 DILEEP410 is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 148
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.
  #2 (permalink)  
Old 01-24-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
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
  #3 (permalink)  
Old 01-24-2007
becket's Avatar
becket becket is offline
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
  #4 (permalink)  
Old 01-24-2007
MizzGail's Avatar
MizzGail MizzGail is offline
Registered User
  
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 164
filelist=`ls directory| grep ilvs_trace`
for q in $filelist
do
echo "file found" $q
done
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 02:06 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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