linux find file modiffied past exact hour
2014-07
I would like to find files that are modiffied past exact hour. example:
File Time Modified
test1.log 14.45PM
test2.log 15.01PM
test3.log 15.15PM
So when i run the find fuction at 15.30PM I want it to display only
- test2.log
- test3.log
Currently my code is
find /root/Desktop/test/ -type f -mmin -60
this will display
- test1.log
- test2.log
- test3.log
I want it to display 15:00PM onwrds file not 1 hour from 15:30 possible?
Change the -60
to however many minutes past sharp the time is.
find /root/Desktop/test/ -type f -mmin -$(date +%M)
The date
command formats its output based on the current time and the format string +%M
produces the minutes field of the current time.
I have a project directory that contains source code and subdirectories of source code. I want to use the Unix program find
to search recursively for the names of files of certain extensions. The versions of find
on Linux and Mac OS X behave differently.
# Works in Linux
find . -type f -regex ".*\.\(py\|html\)$"
# Neither of these works in Mac OS X
find . -type f -regex ".*\.\(py\|html\)$"
find . -type f -regex ".*\.(py|html)$"
How do I write this command so that it will run on Mac OS X (and hopefully on Linux too)?
Mac OS X uses BSD find and most Linux distributions come with GNU find. I believe you can install GNU findutils onto Mac OS X. I don't have a Mac handy, but I am sure it was available in MacPorts.
Looking at the BSD find man page I could make a wild guess and suggest you try looking at the -E
option to enable the modern regular expression library.
The following work with BSD find on OS X.
find -E . -type f -regex ".*\.(py|html)$"
find . -type f | grep -e ".*\.\(py\|html\)$"