开发者

Linux find files and grep then list by date

I'm trying to find files with the name of formClass.php that contain a string of checkCookie and I want to list the files by date showing the date, size, owner and the group. The files are in my home directory.

I have this working, but it do开发者_如何学编程esn't show date, owner, etc...

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

I was thinking that I could add "trhg" to the list like this, but it didn't work:

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

Thanks


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


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

Take a look at man ls for another sorting options.


It seems there are a few ways to do this. I found this and it worked for me. find /home -name formClass.php -exec grep -l "checkCookie" {} \; | xargs ls -ltrhg

thank you for the other suggestions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜