I need a shell script which finds files which are created 1 hour before or 1 hour after a particular file (test.txt
) was created.
If I go with find -newer
, that means I'd have to create a temporary file, use touch
to change the time on that 1 hour before the creation time of the test.txt
file, and then use -newer tempFile
to find the files which are newer than the tempFile
, ultimately finding the files which are created 1 hour before the test.txt file. Then I have to go back through that process to find those an hour or more older than the file I'm interested in. That seems like a lot of extra work to go through to answer a simple question.
I also see find -mmin
, but I worry that it's an extension to POSIX find
.
Any other suggestions?
find
, even GNUfind
, don't make that an easy query. Your best bet is probably to create two temporary files, touch one of them with the oldest time stamp that you want, touch the other with the newest time stamp that you want, and then use-newer
etc. Not neat and tidy. I have tools that would help me, but they're homebrew and not widely available.