The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #27 (permalink)  
Old 07-24-2006
aigles's Avatar
aigles aigles is offline
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,211
I found two problem in your script

$myfilepattern_???_$(date +%Y%m%d) is interpreted by the shell as ${myfilepattern_}???_$(date +%Y%m%d).
You must code like this : ${myfilepattern}_???_$(date +%Y%m%d)


The for statement returns the pattern itself if no file are found.
You must test for that pattern.

Code:
#!/bin/ksh
dir=/biddf/ab6498/dev/ctl
export dir
set -x 
myfilepattern=$@
fullpattern=${my_filepattern}_???_$(date +%Y%m%d)
integer filecount=0
for file in $fullpattern ; do
   [ "$file" != "$fullpattern"] && filecount=$filecount+1
done

if (( $filecount == 10 )); then
print "success"
exit 0
else
print "failure"
exit 1
fi
Jean-Pierre.
Reply With Quote