findのmtimeオプションについて
とりあえず結論を先に
find -mtime -2 x > 2日前 find -mtime 2 2日前 >= x > 3日前 find -mtime +2 3日前 >= x
x は現在、または指定した時刻
実験
自分でもやってみようと啓蒙された記事はこれ
http://doruby.kbmj.com/SK/20090731/find_mtime_
これを自分でも&記事にはない未来のファイルでもやってみようと思った
まず、ファイルの作成
touch -t 03250000 0325.txt(これ未来のファイル) touch -t 03240000 0324.txt touch -t 03230000 0323.txt touch -t 03220000 0322.txt touch -t 03210000 0321.txt
で、テスト
$find -mtime -2 . ./0324.txt ./0323.txt ./0325.txt(これ未来のファイル) $find -daystart -mtime -2 . ./0324.txt ./0323.txt ./0325.txt(これ未来のファイル) $find -mtime 2 ./0322.txt $find -daystart -mtime 2 ./0322.txt $find -mtime +2 ./0321.txt $find -daystart -mtime +2 ./0321.txt
期待通り