Korn Shell & Nawk...Filename changes

I have the following piece of code:

 
 
YESTER=`TZ=aaa24 date +%b"-"%d`
 
filelist2=$(find /export/home/gen/check/logs \( -name \*$YESTER\* ! -name \*ADM\* \) -print | tr '\n' ' ')
 
nawk -F':' '
$2 ~ /Reason/ && $3 !~ /(PASSTHRU|OCAP|FP Power Button|Bootloader Reset)/ {
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])
}' $filelist2 >> $OUTPUT

which basically looks in a certain directory for files that contain the word 'Reason' and splits the filenames, extracting pertinent information. Everything was working smashingly until the beginning of the month, as the date format changed from:

 
10.7.334.245-ADM-Cisco-Jun-30-12-11-22.txt
 

to

 
10.7.334.245-ADM-Cisco-Jul--1-13-22-33.txt.

Any suggestions as to how I can modify the code to accept BOTH types of dates?

turning

 
10.7.334.245-ADM-Cisco-Jul--1-13-22-33.txt

into

 
10.7.334.245-ADM-Cisco-Jul-01-13-22-33.txt
 
YESTER=`TZ=aaa24 date +%b"-"%d | sed 's/--/-0/'`

---------- Post updated at 09:32 PM ---------- Previous update was at 09:29 PM ----------

is the trailing dot '.' expected in :

10.7.334.245-ADM-Cisco-Jul--1-13-22-33.txt.

??

1 Like

No...Sorry, my mistake... it should be:

 
10.7.334.245-ADM-Cisco-Jul--1-13-22-33.txt

---------- Post updated at 04:01 PM ---------- Previous update was at 03:53 PM ----------

Okay, thanks....the only problem is I need it to accept both types of dates because once July 10th rolls around the format will be 'Jul 10' and I do not want to have to manually change the code for this. Any suggestions would be appreciated...