When I deploy my software, I ship a zipped file to the target server and extract its contents. In addition to this, at the same time I also place a metadata file in the directory, detailing what was deployed.
If I want to find any files that have been changed since I deployed the software, I can simply find files that have a new modification time than the metadata file:
find . -newer deployment_metadata.txt
That's nice and straight-forward.
Now, I'd like to also find files that are old than the deployment metadata file. One would assume you could use the bang symbol to negate the "newer" check
find . ! -newer deployment_metadata.txt
But 'not newer' is not quite equivalent to 'older', as any files with the same timestamp are also "not newer" — so the command also includes all the files that I just deployed!
So, I was wondering if I was missing a trick when it comes to finding (strictly) old files?
My current solution is to create a new file (in the temp dir) using touch which has a modification time of one minute before the deployment_metadata.txt file. Then I am able to use the following arguments: ! -newer /var/tmp/metadata_minus_1.
This works, but seems like a waste of time to have to create, and then clean up, the file in the temp dir - especially as different users may be using my script to check for this (don't want file ownership problems, so I actually go as far as appending ${USER} to the filename.