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 files which are created a certain time after or before a particular file was created
shell;shell script;find;date
Another complicated option:get test.txt's modification time (mtime)calculate before delta = now + hour - mtime (assuming mtime is in the past)calculate after delta  = now - hour - mtime if now - mtime > hour else 0run find -type f -mmin -before delta -mmin +after deltaIt finds all files that are modified less than before delta minutes ago and greater than after delta minutes ago i.e., +/- hour around test.txt's modification time.It might be simpler to understand if you draw now, mtime, before, after times on a line.date command allows to get now and mtime.As a one-liner:$ find -type f -newermt $(date -r $file) -1 hour -a \            \! -newermt $(date -r $file) +1 hour