我想要获取目录中特定日期创建的文件
> ll
total 36
-rw-rw-r-- 1 tak tak 212 Oct 08 07:06 name.log
-rw-rw-r-- 1 tak tak 494 Oct 09 09:24 rep.083011
-rw-rw-r-- 1 tak tak 494 Oct 08 05:27 rep.083221
-rwxrwxr-x 1 tak tak 914 Oct 09 09:29 names.ksh
-rw-rw-r-- 1 tak tak 331 Oct 08 09:28 report_091020130928.txt
-rw-rw-r-- 1 tak tak 331 Oct 09 12:00 report_091020131200.txt
drwxrwxr-x 2 tak tak 2048 Oct 08 08:44 error
-rwxrwxr-x 1 tak tak 2 Oct 09 08:36 sample.ksh
-rw-rw-r-- 1 tak tak 92 Oct 08 06:17 x.log
我使用了下面的命令
find . -type f -newer 2013-10-08 ! -newer 2013-10-08
这给出了一个错误
find: 0652-015 Cannot access file 2013-10-07
答案1
从man find
:
-newer file
File was modified more recently than file. If file is a sym‐
bolic 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
测试预计文件作为参数而不是日期字符串。因此,您可以将其指向具有正确修改日期的文件,也可以使用-mtime
:
-mtime n
File's data was last modified n*24 hours ago. See the comments
for -atime to understand how rounding affects the interpretation
of file modification times.
Numeric arguments can be specified as
+n for greater than n,
-n for less than n,
n for exactly n.