IF loop to check the time modified

Hi Frnds,

i have a folder test in which files generated daily how to chek the files that are modified on that day as a condition for ex,

if [ file is modified today ]
then echo "i have got something to do with the file"
else
echo" sorry"
fi

i will have more than 3 to 4 files that are modified today. and if they are modified i have some process to do with that. Please help me

You can use -mtime of find(1). -mtime -1 would list files newer than 24 hours. Alternatively, you can make a timestamp every midnight (from cron), and check with -nt, if your shell's test implementation has it. See man test for details. E.g.:

find /path/to/dir -mtime -1 > newFiles.lst
...
if grep -q $file newFiles.lst ; then 
  echo "file $file is new"
else
  echo "old stuff"
fi

or

if [ $file -nt $timestamp ] ; then
  echo "$file is new"
fi

Hi Mirni,

 Thanks for th eprompt reply..... i think this will defenitely help me...  is -mtime -1 will get the files modified 1 day back right? is there any way to get files modified 30 mins ago...

less than 30 minutes ago: -mmin -30
It's all in the manual: man find

Thanks a lot mirni..... find /mahe -mmin -30 | grep Data gives me name of the files greping Data. but i not ly need the name of file alone , i need the ouput like ls -l (ie) date time ,size,rwx acesss etc... Please help me..

find /mahe -mmin -30 -ls