查找具有特定名称和特定日期命令的文件返回错误的结果

时间:2017-10-29 13:41:58

标签: linux centos

我正在使用centos 7 如果我想在目录A

中找到以单词image开头的文件

我发出以下命令

  find  /A -name 'image*'

并且为了编写查找具有特定名称并在特定日期发布的文件的命令,并将其作为例如25/10/2017

我发出命令

find -name 'image*' | ls -ali | grep 'Oct 25'

但是它会压缩文件夹中的所有文件

中的错误

2 个答案:

答案 0 :(得分:1)

您可以使用find打印上次修改的日期:

find -name 'image*' -printf "%TD %p\n" | grep "^10/25"

或:

find -name 'image*' -ls | grep "Oct 25"

答案 1 :(得分:0)

你的命令似乎错了,你可能错过了xargs

find -name 'image*' | xargs ls -ali | grep 'Oct 25'

没有xargs,find的输出就会被丢弃,你拿走当前目录的ls -ali,这可能不是你想要的。

然而,找到了将日期添加为搜索条件的选项,不确定这是你真正需要的,但你可能看看

How to use 'find' to search for files created on a specific date?