特定のサイズと修正時間に一致するファイルをお探しですか?

特定のサイズと修正時間に一致するファイルをお探しですか?

ディレクトリ内の特定のサイズ(15KBなど)より大きく、過去10日間に変更されたすべてのファイルをどのように見つけることができますか?

ベストアンサー1

私はそうします:

find /directory -mtime -10 -size +15k

/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.

-size 15kつまり、15KBを超えるファイルを探します。

  -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).

これが問題の一種である場合は、システムにfind(1)入力してオペレーティングシステムのマニュアルを読んで、その仕組みを実際に理解してください。man find

おすすめ記事