Linux will find files and grep, and then list by date

I am trying to find files called formClass.php that contain the string checkCookie , and I want to list the files by date with date, size, owner and group. Files are in my home directory.

It works for me, but it does not show the date, owner, etc.

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

I thought I could add "trhg" to a list like this, but this did not work:

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

thanks

+4
source share
3 answers

Try 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

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

See man ls for other sorting options.

+2
source

There seem to be several 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 other suggestions.

0
source

All Articles