【问题标题】:How to Find Recent or Today’s Modified Files in Linux如何在 Linux 中查找最近或今天修改过的文件
【发布时间】:2020-06-01 15:42:54
【问题描述】:

我有一个要求,必须找出最新修改的文​​件列表以及日期和时间。 主要是我们有 2 个文件,它们是 boot.properties 和 ldap 相关文件,作为 beadmin 密码更改活动的一部分。

find /target_directory -type f -name "*boot.properties" -exec ls -ltr {} \;

只提供 boot.properties 但我需要找到位于不同位置的其他文件。

【问题讨论】:

    标签: linux file date unix timestamp


    【解决方案1】:

    如果您有不同的位置和文件名,请尝试这样的操作。

    find /root_directory \
    \( \( \
     -path "/target_directory1/*" -type f  -name "*boot.properties" \) -o \( \
     -path "/target_directory2/*" -type f  -name "*boot2.properties" \
     \) \) -exec ls -ltr {} \;
    
    

    此外,您还可以通过修改日期查找其他选项。 检查这篇文章 https://www.cyberciti.biz/faq/linux-unix-osxfind-files-by-date/

    【讨论】:

      【解决方案2】:

      find 支持多个路径参数,因此您可以执行类似的操作

      find /target_dir /other -type f \( -name "*boot.properties" -o -name "other*" \) -exec ls -ltr {} +
      

      【讨论】: