![](/img/trans.png)
[英]How to grep contents from list of files from Linux ls or find command
[英]Linux find files and grep then list by date
我正在尝试查找名称为formClass.php
的文件,其中包含一个checkCookie字符串,我想按日期列出文件,显示日期、大小、所有者和组。 这些文件在我的主目录中。
我有这个工作,但它不显示日期,所有者等......
find /home -name formClass.php -exec grep -l "checkCookie" {} \;
我在想我可以像这样将“trhg”添加到列表中,但它不起作用:
find /home -name formClass.php -exec grep -ltrhg "checkCookie" {} \;
谢谢
尝试find /home -name formClass.php -print0 | xargs -0 grep -l --null checkCookie | xargs -0 ls -l
find /home -name formClass.php -print0 | xargs -0 grep -l --null checkCookie | xargs -0 ls -l
ls -lt `grep -lr --include=formClass.php "checkCookie" *`
查看man ls
以获取其他排序选项。
似乎有几种方法可以做到这一点。 我发现了这个,它对我有用。 查找 /home -name formClass.php -exec grep -l "checkCookie" {} \; | xargs ls -ltrhg
谢谢你的其他建议。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.