【问题标题】:Linux find files and grep then list by dateLinux 查找文件和 grep 然后按日期列出
【发布时间】:2011-05-24 15:46:36
【问题描述】:

我正在尝试查找名称为 formClass.php 且包含 checkCookie 字符串的文件,并且我想按日期列出文件,显示日期、大小、所有者和组。这些文件在我的主目录中。

我有这个工作,但它不显示日期、所有者等......

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

我在想我可以像这样将“trhg”添加到列表中,但它不起作用:

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

谢谢

【问题讨论】:

    标签: linux list find grep exec


    【解决方案1】:

    试试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 了解其他排序选项。

      【讨论】:

        【解决方案3】:

        似乎有几种方法可以做到这一点。我发现了这个,它对我有用。 查找 /home -name formClass.php -exec grep -l "checkCookie" {} \; | xargs ls -ltrhg

        感谢您的其他建议。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-02-26
          • 2015-12-24
          • 1970-01-01
          • 1970-01-01
          • 2016-04-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多