Hi All
I have a file having columns such as
AAA,BBB,CCC,Aug 13 2013
AAA,BBB,CCC,Aug 11 2013
AAA,BBB,CCC,Aug 12 2013
AAA,BBB,CCC,Aug 13 2013
Now I need to extract the records which are not of todays date (Considering Today date is 13-Aug-2013
So I should get below records
AAA,BBB,CCC,Aug 11 2013
AAA,BBB,CCC,Aug 12 2013
in a file
This is what am doing
Creating a file with only first and forth record via awk
-----------------------------------
cat $FILE_NAME | awk 'BEGIN{FS=",";}
{
#where = match($4,$TODAY_DATE)
#if(match)
print substr($1,1,3),"~",substr($4,1,11);}
END{;}' >> $DATE_IN_FILE
-------------------------------------
Now for comparing date am using the below
TODAY_DATE=`date +"%b %d %Y"`
cat $DATE_IN_FILE | awk 'BEGIN{FS="~";}
{
val=index($2,$TODAY_DATE)
if($val>0)
print "Inside IF"
else
print "Inside else"
;}
END{;}' >> $INCORRECT_RATE
The issue is because the Date is having multiple words Aug 12 2013 and hence Index is not working (Since Aug matches and hence it returns the value)
Please suggest