linux:搜索最近修改的*.php类型的文件

linux:搜索最近修改的*.php类型的文件,linux,find,Linux,Find,我如何调整它以递归方式返回仅扩展名为*.php的文件?谢谢 find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort 您可以在中找到更多选项。添加-name'*.php': find . -type f -name '*.php' -printf '%TY-%Tm-%Td %TT %p\n' | sort 请注意,由于表达式是由find从左到右计算的,因此必须在-printf操作之前指定-name测试 有关测试、操作以及find如何计算表达式

我如何调整它以递归方式返回仅扩展名为*.php的文件?谢谢

find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort

您可以在中找到更多选项。

添加
-name'*.php'

find . -type f  -name '*.php' -printf '%TY-%Tm-%Td %TT %p\n' | sort
请注意,由于表达式是由
find
从左到右计算的,因此必须在
-printf
操作之前指定
-name
测试

有关测试、操作以及find如何计算表达式的详细信息,请参阅。

您也可以使用

find . -type f -mtime -n -name '*.php' | sort    
其中n是文件存在的天数。比如说

find . -type f -mtime -1 -name '*.php' | sort 

应返回少于一天的所有文件。如果您想筛选结果,这很有用。

说明:使用unix命令find with
-type
标志和regex作为
.php
文件结尾和
-ctime
作为创建时间

find实用程序递归地为列出的每个路径下放到目录树中,根据树中的每个文件计算表达式(由“primary”和“operans”组成)

解决方案:
查找-名称“*\.php”-type f-mtime-4w
-这意味着在我的当前目录中找到在过去4周内创建的类型文件中的所有php组合名称

额外阅读:根据文档

 -type t
         True if the file is of the specified type.  Possible file types are as fol-
         lows:

         b       block special
         c       character special
         d       directory
         f       regular file
         l       symbolic link
         p       FIFO
         s       socket

 -mtime n[smhdw]
         If no units are specified, this primary evaluates to true if the difference
         between the file last modification time and the time find was started,
         rounded up to the next full 24-hour period, is n 24-hour periods.

         If units are specified, this primary evaluates to true if the difference
         between the file last modification time and the time find was started is
         exactly n units.  Please refer to the -atime primary description for informa-
         tion on supported time units.

-name
应在
-printf
之前指定。
 -type t
         True if the file is of the specified type.  Possible file types are as fol-
         lows:

         b       block special
         c       character special
         d       directory
         f       regular file
         l       symbolic link
         p       FIFO
         s       socket

 -mtime n[smhdw]
         If no units are specified, this primary evaluates to true if the difference
         between the file last modification time and the time find was started,
         rounded up to the next full 24-hour period, is n 24-hour periods.

         If units are specified, this primary evaluates to true if the difference
         between the file last modification time and the time find was started is
         exactly n units.  Please refer to the -atime primary description for informa-
         tion on supported time units.