4
1
I need to find files within a date range to the minute. I suppose knowing how to do it to the second might be beneficial one day. Anyhow. I've learned how to use -newermt and even -not -newermt; however, I can't seem to get correct results when I combine them. I found linux examples of using find, but don't think the switches are working on OSX. See the following list of files:
#$ ls -l
total 32
-rw-r--r-- 1 testuser staff 1024 Oct 26 20:12 test1.swc
-rw-r--r-- 1 testuser staff 0 Oct 26 19:00 test1_old.swc
-rw-r--r-- 1 testuser staff 1024 Oct 26 20:12 test2.swc
-rw-r--r-- 1 testuser staff 0 Oct 26 19:00 test2_old.swc
-rw-r--r-- 1 testuser staff 1024 Oct 26 20:12 test3.swc
-rw-r--r-- 1 testuser staff 0 Oct 26 19:00 test3_old.swc
-rw-r--r-- 1 testuser staff 1024 Oct 26 20:12 test4.swc
-rw-r--r-- 1 testuser staff 0 Oct 26 19:00 test4_old.swc
-rw-r--r-- 1 testuser staff 0 Oct 26 20:11 test5.swc
-rw-r--r-- 1 testuser staff 0 Oct 26 20:13 test6.swc
-rw-r--r-- 1 testuser staff 0 Oct 26 19:00 timestamp.tmp
I would expect the following command to return test1.swc through test4.swc; however, notice that it returned test6.swc:
#$ find . -newermt '2010-10-26 20:11' -a -not -newermt '2010-10-26 20:13'
./test1.swc
./test2.swc
./test3.swc
./test4.swc
./test6.swc
I thought the minute for the -not condition was off so I tried the following, but it returned nothing:
#$ find . -newermt '2010-10-26 20:11' -a -not -newermt '2010-10-26 20:12'
#$
I've concluded that I'm not properly combining the -newermt and -not -newermt switches. Any advice on how to correct this?
That also returns nothing on my fileset. I created the files using touch -mt. The last file, test6.swc was created a while later than the others, but with the following: touch -mt 201010262013 test6.swc Still it is listed in the result set if I use: find . -newermt "2010-10-26 20:11" ! -newermt "2010-10-26 20:13", which hints that maybe even the syntax you suggested is failing (I don't think the time should be 20:12 on the '!' condition, I think it should be 20:13) – Michael Prescott – 2010-10-27T04:17:29.510
Sorry I edited the post, I had two version I was working on and copied the wrong one in. – Robert Leckie – 2010-10-27T04:26:10.673
Thanks for the help. Using your example and a new fileset I found the problem. I created a new fileset with touch -mt 201010262010 test1_new.swc test2_new.swc test3_new.swc test4_new.swc and touch -mt 201010262011 test5_new.swc. Then I executed the command: find . -newermt "2010-10-26 20:10" ! -newermt "2010-10-26 20:11", which returned just the test5_new.swc, instead of the desired 1 through 4. However, when I used, find . -newermt "2010-10-26 20:09:59" ! -newermt "2010-10-26 20:10:59" I got the results I expected. – Michael Prescott – 2010-10-27T04:41:26.337