查找匹配特定大小和修改时间的文件?

aja*_*jay -4 find shell-script

如何找到目录中大于特定大小(例如 15 KB)且在过去 10 天内已修改的所有文件?

Wil*_*ill 5

我会这样做:

find /directory -mtime -10 -size +15k
Run Code Online (Sandbox Code Playgroud)

/directory是基本目录,其中搜索被预成形(通过递归默认)。

-mtime 10 意味着它将查找在过去 10 天内修改过的文件:

  -mtime n
          File's data was last modified n*24 hours ago.  See the comments for -atime to understand how rounding affects the interpretation of file modi-
          fication times.
Run Code Online (Sandbox Code Playgroud)

-size 15k 意味着它将查找大于 15 KB 的文件:

  -size n[cwbkMG]
          File uses n units of space, rounding up.  The following suffixes
          can be used:

          `b'    for 512-byte blocks (this is the default if no suffix is used)
          `c'    for bytes
          `w'    for two-byte words
          `k'    for Kilobytes (units of 1024 bytes)
          `M'    for Megabytes (units of 1048576 bytes)
          `G'    for Gigabytes (units of 1073741824 bytes)

          The  size  does  not  count  indirect  blocks, but it does count
          blocks in sparse files that are not actually allocated.  Bear in
          mind  that the `%k' and `%b' format specifiers of -printf handle
          sparse  files  differently.   The  `b'  suffix  always   denotes
          512-byte  blocks and never 1 Kilobyte blocks, which is different
          to the behaviour of -ls.  The + and - prefixes  signify  greater
          than  and less than, as usual, but bear in mind that the size is
          rounded up to the next unit (so a 1-byte file is not matched  by
          -size -1M).
Run Code Online (Sandbox Code Playgroud)

如果这是某种家庭作业问题,请find(1)通过man find在您的系统上键入来阅读您的操作系统的手册,并真正了解它是如何工作的。