Search code examples
linuxlistfindgrepexec

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 doesn'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


Solution

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