I'm sure this is an age old question with a simple answer, but I've tried every combination I know to try and haven't come up with anything. And searching Google is less than pleasant since searching this topic comes up with hundreds of way to "find yesterday's date using the date command".
Anyway, I am trying to use find to select a list of files that were modified yesterday. The goal is to select yesterday's log files out of a directory to do something specific with them. The directory contains multiple days of log output.
The best I can get is find returning yesterday's files WITH today's files listed as well. I do not want to see today's files -- just yesterday.
I will also throw in the gotcha: this is AIX find, NOT the GNU find you'd find in most Linux distros. So -daystart
is not an option available to me. (Thought of that one already!)
Anyone know an effective way to list out yesterday's files using find on AIX?
One possibility: build GNU 'find' on your box and use that instead of the stock 'find'.
Or, if AIX find has the -newer test, you could do something like this:
You can deduct the number of minutes of the current time since midnight and use
-mmin
:You might need to make some adjustments to the offsets. I don't have many files at the right times to do a lot of edge-case testing.
Won't
find . -mtime 1
do the trick?If you need it to be yesterday and can't run it close to midnight, I suppose you could work someting out with using two -mmin options to specify a bracket of time.
So if it's 01:00 you could do
find . -mmin +60 -mmin -1500
Depending on what you need to do with them, how about a simple ls + grep solution?