Find files in directories
So i have directories that store logs, 1 directorie for each day, with the name like this :
2012_07_01/
2012_07_02/
and for each directorie we have the logs, inside them lives the logs for that day, and every log have this name pattern :
sensor1_log_from_2012_07_01_10_:_30_to_2012_07_01_10_:_50
and every file have 100 mb
now i presente the env i can tell the problem i have is my script that i will show on the bottom will show you how i do things right now but, question is if i have a leap in days or hours or anything between my $startdate and $enddate value that i use to search for the files that i want to see in the directorie logs, then a problem comes because we can have logs that came like this :
sensor1_log_from_2012_07_01_10_:_30_to_2012_07_03_10_:_30
and think on this what if i want to see logs from 2012_07_02 ??? and this can happen because if a sensor dont collect enough traffic for the 100 mb then he goona leaps the end date until it reachs the 100mb
but, for this i'm thinking or if i can search for the last know file before the date i search ? that would do the trick but i dont know how to do it right now i have this :
Code:
for dir in `ls | sort | sed -n "/$startdate/,/$enddate/p"` ; do
if [ `ls $dir | wc -l` -gt 0 ] ; then
ls $dir
else
rmdir $dir
fi
done
soo with that said can anyone give me a hand , i know some people use find like:
find ${DIR} \ (-name $startdate and $enddate) -ctime > /tmp/list.txt
i just dont know how to combine that in my script in the right way.