mtime

Hi,

I've some files of some past days and everyday some new files are also getting added to the same.

Now how can i use mtime to get the files of the current date i.e if i want the files of 25th feb 2009 and if im finding the files on 25th 12:10 am then i should only get the files after 12:00 am of 25th feb 2009.

right now im doing it this way but this gives me the files modified less than 1 day ago i.e., within the past 24 hours, as before.

find . -name '*.xml' -mtime -1 -exec basename {} \; >>Today.xml

A crude but simple way will be:

touch -t 200902250000 /tmp/newer_than_this
find . -name '*.xml' -newer /tmp/newer_than_this -exec basename {} \; >>Today.xml

Easier than calculating mtime arguments since the -t parameter for touch is much more readable (YYYYMMDDhhmm format). Not sure if the GNU find has friendlier options.

I cant hardcode the timestamp as at any point of time of any day the script will be run and then it needs to search for the current day's files.

Show a little initiative in doing some research. (sigh) here goes:

touch -t `date "+%Y%m%d0000"` /tmp/newer_than_this 

thnx a lot.

now getting the desired output :slight_smile: