simple script

i have a script that check for the last date entry made in a series of files
--------------------------------------------------------------------

a=`date +"%Y-%m-%d"`

for i in *.log*
do
cat $i | grep $a

echo $i >> file1.txt
echo $a >> file1.txt
done
-----------------------------------------------------------------------

but this format of date i,e "a" checks for current/today date .

i want the date that checks the last date put into that files.the format should be same as y-m-d
-----------------------------------------------------------------------

If you want to select the file which are created in the latest date, you have to do like this :

mon=`ls -lrt | awk '{print $6}' | tail -1`
day=`ls -lrt | awk '{print $7}' | tail -1`

for file in `ls -l | grep "$mon $day" | awk '{print $9}'`
do
echo $file
done