I have filenames
filenameA_fg_MMDDYY.tar.gz
filenameASPQ_fg_MMDDYY.tar.gz
filenameAFTOPHYYINGH_fg_MMDDYY.tar.gz
filenameAGHYSW_fg_MMDDYY.tar.gz
My requiremnt needs to extract date which is in MMDDYYand change it into YYYYMMDD format.
I have done the following:
filedate=`echo $filename | awk -F"[_.]" '{print $(NF-2)}'`
formatdate = `echo $filedate | awk 'BEGIN {OFS=""}{print 20 substr($1,5,2), substr($1,1,2), substr($1,3,2)}'`
if [ formatdate -lt myowndate ]
This comparison doesnot work . I have tried putting quotes, < everything nothing works. I understand the problem is formatdate datetype is actually string and so it is not doing the compare.
Is there a way where I can change the MMDDYY date to YYYYMMDD number format . Basically what i need is the YYYYMMDD format to be number datatype . Any solution . I apologise if im not clear.



