[英]On Linux, FIND command with LS not showing proper result without option -d
I need to check all the files created in last day inside current folder which has million of files. 我需要检查当前文件夹中最后一天创建的所有文件,其中包含数百万个文件。
If I used following command correct 80 or 90 files are shown. 如果我使用以下命令,将显示正确的80或90个文件。 which is correct.
哪个是对的。
find . -ctime -1 -exec ls -ld {} \;
but if I change ls option to rt or l or anything else without d. 但是如果我将ls选项更改为rt或l或其他没有d的选项。 it shows wrong result.
它显示错误的结果。 It shows thousands of file.
它显示了数千个文件。 I eventually have to press control C to stop the output.
我最终不得不按C键来停止输出。 All following are wrong never ending results.
以下所有错误都是永无止境的结果。
find . -ctime -1 -exec ls -l {} \;
find . -ctime -1 -exec ls -t {} \;
find . -ctime -1 -exec ls -rt {} \;
find . -ctime -1 -exec ls {} \;
Can someone tell what is going on here. 有人可以告诉我这是怎么回事。 Why it works only with d.
为什么它仅适用于d。 following works though
虽然下面的作品
find . -ctime -1 -exec ls -lrtd {} \;
If you do ls /tmp
, you'll see why. 如果执行
ls /tmp
,则会明白原因。 It gives you all the files in the /tmp
directory rather than the details on the directory itself. 它为您提供
/tmp
目录中的所有文件,而不是目录本身的详细信息。
You can 'fix' this by using -d
to have ls
show the directory rather than the files within it (as you've seen) or by using find -type f
to restrict your search to regular files only. 您可以使用
-d
使ls
显示目录而不是其中的文件(如您所见),或者使用find -type f
将搜索限制为仅常规文件,从而“修复”此问题。 That's assuming it's only regular files you're interested in, there are also things like FIFO pipes and devices which exist in the hierarchy, but there are other variations on -type
that will pick those up if needed (see find
man page for details). 假设这只是您感兴趣的常规文件,层次结构中还存在诸如FIFO管道和设备之类的东西,但是
-type
上还有其他变体可以在需要时进行选择(有关详细信息,请参见find
手册页) 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.