I'm trying to delete a file from 12 hours ago开发者_如何学JAVA only anything over 12 hours ago I just want to append.
find . -name "forum*.sql" -mmin +600 -mmin -780 -delete
Is there something like a -mmax I have to define?
Sorry, but I found your description a little hard to parse too.
Here is code that will delete files that are exactly created/modified in the 12-13th hour ago. Older files and newer files are left in place.
Forgive the verboseness of the var names, it's late, and I'm hoping that they make this solution self-documenting.
# currentTime=201104272232
TwelveHrsBefore=201104271032
ThirteenHrsBefore=2001104270932
# make some zero files with date/time range for what is to be deleted.
touch -t ${TwelveHrsBefore} upperLimit.tmpFile
touch -t ${ThirteenHrsBefore} lowerLimit.tmpFile
find . -name "forum*.sql" -newer lowerLimit.tmpFile -a ! -newer upperLimit.tmpFile
# when the above is producing the list of files you want to delete,
# append "| xargs /bin/rm -i" to the end of the find command
# to delete the files
# cleanup your tmp files
rm lowerLimit.tmpFile upperLimit.tmpFile
The -newer ... -a ! -newer ...
can be frustrating to get right. I have lightly tested it today AND I have used this technique for production jobs in the past, but I don't have access to that code to review what was a more complex problem than this example.
I hope this helps.
精彩评论