I'm using the following to find all files that are older than a reference file...
find /home/testuser -name "dummyfiles*" ! -newer referencefile.txt
... which works as expected.
However, I want to add a bit of leniency to the time, so that it only finds files that are older than the reference file - a few hours.
For example, if I have a reference file with modification date May 26 11:26
, I want to find files that are older than May 26 9:26
(ie, with a 2-hour leniency on the reference file).
In this example, the following would be correct matches...
May 26 7:00
Apr 15 14:00
... and the following should not match...
Jun 13 9:00
May 26 10:00
Ultimately I want to delete all the files that I find, so would love it if find
was able to handle this requirement? Otherwise, are there any other alternatives that will allow me to delete these files without being too convoluted?
May 26 9:26
, so it should also match files with datesMay 26 7:00
,Apr 15 14:50
, ... but not match datesJun 13 9:00
orMay 26 10:00
.