开发者

Linux find files and grep then list by date

开发者 https://www.devze.com 2023-03-07 22:07 出处:网络
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

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

精彩评论

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