Let's say it is 10:00 am when the command is run, I need to list the files modified between midnight and 9:55 am.
I have tried the following command which looks logical as per the documentation but it is pulling all the files since yesterday.
-rw-r----- 1 anami anami 0 Jan 26 17:51 a
-rw-r----- 1 anami anami 0 Jan 26 18:18 b
-rw-r----- 1 anami anami 0 Jan 26 01:00 c
-rw-r----- 1 anami anami 0 Jan 25 10:00 d
-rw-r----- 1 anami anami 0 Jan 27 12:21 e
-rw-r----- 1 anami anami 0 Jan 27 12:52 f
$ find . -daystart -mmin +5
./a
./g
./d
./c
./e
./b
./f
Since -daystart
isn't that portible, consider a solution like so;
Use $(date +"%H")
to get the current hour , in your test case, this should be 10
.
Multiply that number by 60 to get the desired minutes
Subtract 5 minutes to get the number of minutes between 00:00 and 09:55
Use that value for the -mmin
param
currentHour=$(date +"%H")
minutes=$(( 60 * currentHour - 5 ))
find . -mmin "-${minutes}" -mmin +5
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.