find -newer 精确度问题
man find 输出关于'-newer'参数描述如下
-newer file
File was modified more recently than file. If file is a symbolic link and the -H option or the -L option is in effect, the
modification time of the file it points to is always used.
-newer 参数目的是查找比指定文件时间戳晚的文件,例如:
$ ls -lrt
-rw-r----- 1 root root 0 Oct 20 10:57 test1
-rw-r----- 1 root root 0 Oct 20 10:58 test2
$ find ./ -type f -newer test1 -name "*"
./test2
这是我在Redhat 6.2下的运行情况。'-newer' 参数能使find找到哪怕比指定文件的时间戳大0.000000001秒的文件。
$ ls -l --time-style=full-iso
total 0
-rw-r----- 1 root root 0 2012-10-20 10:57:56.474739829 +0800 test1
-rw-r----- 1 root root 0 2012-10-20 10:58:00.711765596 +0800 test2
$touch -d "2012-10-20 10:57:56.474739830" test2
$ ls -l --time-style=full-iso
total 0
-rw-r----- 1 root root 0 2012-10-20 10:57:56.474739829 +0800 test1
-rw-r----- 1 root root 0 2012-10-20 10:57:56.474739830 +0800 test2
test2只比test1晚了0.000000001秒
$ find ./ -type f -newer test1 -name "*"
./test2
但在某些系统下,如我试过的SunOS 5.10 上'find -newer'的精准度就有限了,如果所要找的文件比指定文件时间戳大1秒以内,就不会被
找到。