LoginSignup
230
214

More than 3 years have passed since last update.

findコマンドのmtimeオプションまとめ

Last updated at Posted at 2015-11-19

findコマンドの時間指定は色々パターンがあるので、
まとまてみました。


時間指定オプション一覧。

オプション 概要
-mmin ファイルのデータが最後に修正された日時(分指定)
-mtime ファイルのデータが最後に修正された日時(日指定)
-amin ファイルのデータに最後にアクセスされた日時(分指定)
-atime ファイルのデータに最後にアクセスされた日時(日指定)
-cmin ファイルのデータとステータスが最後に修正された日時(分指定)
-ctime ファイルのデータとステータスが最後に修正された日時(日指定)

現在から3日前まで(現在時間〜72時間前)

# find ./ -mtime -3

3日前(72時間前〜96時間前)

# find ./ -mtime 3

過去から3日前まで(72時間前〜過去)

# find ./ -mtime +2

※ (2+1)日前以降


daystartオプションを指定すると0時を基準にします。
1日単位で範囲指定したい場合に使用します。

例として、現在を12月24日03時00分とします。

現在から3日前まで(12月24日24時00分〜72時間前)

# find ./ -daystart -mtime -3

3日前(12月21日24時00分〜24時間前)

# find ./ -daystart -mtime 3

過去から3日前まで(12月21日24時00分〜過去)

# find ./ -daystart -mtime +2

※ (2+1)日前以降


少数指定も出来るみたいです。

12時間前まで(現在時間〜12時間前)

# find ./ -mtime -0.5

230
214
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
230
214