ksh/nawk help with if statement to choose between 2 files

Hi! I am having a bit of a problem with my script. There are two different date formats that may appear in a file, either Jul-12 or Jul--6. I tried to create an if statement that searches for one of the formats and if that doesn't exist searches for the other, however it doesn't seem to be working. Please see below:

 
YESTER=`TZ=aaa24 date +%b"-"%d`
 
YESTERF=`TZ=aaa24 date +%b"-"%d | sed 's/-0/--/'`
 
filelista=$(find /export/home/gen/cks/traces \( -name \*$YESTERF\* ! -name \*DNA\* \) -print | tr '\n' ' ')
filelistb=$(find /export/home/gen/cks/traces \( -name \*$YESTER\* ! -name \*DNA\* \) -print | tr '\n' ' ')
 
if [[ ! -e $filelista ]]
then
filelist=$filelistb
elif [[ -e $filelista ]]
then
filelist=$filelista 
else
print "No filelist found!"
fi
 
print "Date/Time,Location,Shelf,IP,Reason,Log Filename" >> $OUTPUT
nawk -F':' '
$2 ~ /Reason/ && $3 !~ /(PASSTHRU|OCP|FP Power Button|Bootloader|PFR|MEM)/ {
split(FILENAME, a, "-")
f = a[1]
while (i = index(f, "/")) f = substr(f, i+1)
sub("\r$", "");
printf("%s %s,%s %s,%s,%s,%s,%s-%s-%s-%s-%s-%s-%s-%s-%s\n", a[5], a[6], a[2], a[3], a[4], f, $0, f, a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9])
}' $filelist >> $OUTPUT

I think it has to do with the if statement as I ran it previously with only on of the two filelists and it worked properly. However, when the date changes to Jul10th and on I will need it to switch to the other format.

Check if your date implementation supports the no-pad flag:

% date +%b-%d; date +%b--%-d; date -d '+3 days' +%b--%-d
Jul-07
Jul--7
Jul--10
1 Like

I don't think it does..I didn't see anything about it in the man pages and this is the error I got:

 
 
Jul--%-d
PSP6-SYSG-PC1>>date -d '+3 days' +%b--%-d
date: illegal option -- d
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]
PSP6-SYSG-PC1>>^C
PSP6-SYSG-PC1>>
 

Thank you though. I actually think I was able to make it work using an if statement:

 

TODAY1=$(date +"%b-%d" | sed 's/-0/--/')
TODAY2=$(date +"%b-%d")
TODAY_DAY=$(date +"%d")
print $TODAY_DAY
if (($TODAY_DAY < 10))
then
TODAY=$TODAY1
elif (($TODAY_DAY >= 10))
then 
TODAY=$TODAY2
else
print "Error with date computation!"
fi

I suppose I wasn't clear enough, the no pad flag is the dash (-) right after the %:

$ date +%d; date +%-d
08
8

Anyway it seems a GNU extension.