Linux 查找文件并 grep 然后按日期列出

问题描述 投票:0回答:3

我正在尝试查找名称为

formClass.php
且包含字符串 checkCookie 的文件,并且我想按日期列出文件,显示日期、大小、所有者和组。这些文件位于我的主目录中。

我可以使用此功能,但它不显示日期、所有者等...

find /home -name formClass.php -exec grep -l "checkCookie" {} \;

我想我可以像这样将“trhg”添加到列表中,但它不起作用:

find /home -name formClass.php -exec grep -ltrhg "checkCookie" {} \;

谢谢

linux list find grep exec
3个回答
6
投票

尝试

find /home -name formClass.php -print0 |  xargs -0 grep -l --null checkCookie | xargs -0 ls -l


2
投票
ls -lt `grep -lr --include=formClass.php "checkCookie" *`

查看

man ls
了解其他排序选项。


0
投票

似乎有几种方法可以做到这一点。我发现了这个,它对我有用。

find /home -name formClass.php -exec grep -l "checkCookie" {} \; | xargs ls -ltrhg

谢谢您的其他建议。

© www.soinside.com 2019 - 2024. All rights reserved.