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.