2011-05-24 78 views
4

我試圖找到名稱爲formClass.php的文件,其中包含字符串checkCookie我想按日期列出文件,顯示日期,大小,所有者和組。這些文件在我的主目錄中。Linux找到文件和grep然後按日期列出

我有這個工作,但它並沒有顯示日期,所有者等等

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

我在想,我可以添加「trhg」到列表這樣的,但它沒」將不起作用:

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

感謝

回答

6

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

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

看看man ls爲另一個排序選項。

0

看來有幾種方法可以做到這一點。我發現這一點,它爲我工作。 find/home -name formClass.php -exec grep -l「checkCookie」{} \; | xargs ls -ltrhg

謝謝你的其他建議。

相關問題