There are files of same name getting generated on a daily basis .
I have got the file names in a file . Now what my script does is read the file , check for existence of filename and increment a counter by 1 .
Now sometimes what happens is that the previous day's file gets counted in case the file for today has not yet GNTDand overwrtes the prev days file .
To handle this case of not taking into account the previous days file . I have put in a check which checks the file creation date should be equal to current date .
One idea is to create a reference file with "touch" with a timestamp at the start of the day, then compare the timestamp.
Not tested with your exact shell.
YYYYMMDD="`date +%Y%m%d`" # Reversed date yyyymmdd
REFERENCE=/var/tmp/reference.${YYYYMMDD}.$$
touch -t ${YYYYMMDD}0000 ${REFERENCE} # Start of today
cntr=0
while read line
do
if [ -e "${line}" ]
then
if [ "${line}" -nt "${REFERENCE}" ]
then
let cntr=$cntr+1
fi
fi
done < file_list
rm "${REFERENCE}"
Thanks for ur help ... ur script tickled my brains gray matter and what i have done is this
curr_date=`date +'%d'`
cntr=0;
while read line
do
if [ -e "${line}" ]
then
if [ `ls -lrt $line | awk {'print$7'}` -eq $curr_date ]
then
let cntr=$cntr+1
fi
fi
done < file_list