私は1年以上古いファイルを削除するために以下のコマンドを使いました。linuxの特定の日付より古いファイルを削除する
find /path/* -mtime +365 -exec rm -rf {} \;
しかし、今私は、その変更された時間、私は、Linuxでそれを行うにはどうすればよい2014年1月
よりも古い01であるすべてのファイルを削除したいです。
私は1年以上古いファイルを削除するために以下のコマンドを使いました。linuxの特定の日付より古いファイルを削除する
find /path/* -mtime +365 -exec rm -rf {} \;
しかし、今私は、その変更された時間、私は、Linuxでそれを行うにはどうすればよい2014年1月
よりも古い01であるすべてのファイルを削除したいです。
あなたはファイルとしてタイムスタンプを触れると基準点としてそれを使用することができます
例えば01-JAN-2014用:find
は、私たちが使用している-newer
スイッチを持っているので、
touch -t 201401010000 /tmp/2014-Jan-01-0000
find /path -type f ! -newer /tmp/2014-Jan-01-0000 | xargs rm -rf
これは動作します。 man find
から
:
-newer file
File was modified more recently than file. If file is a symbolic
link and the -H option or the -L option is in effect, the modification time of the
file it points to is always used.
これが私の作品:
find /path ! -newermt "YYYY-MM-DD HH:MM:SS" | xargs rm -rf
ありがとうございました。 ! -not -newer/tmp/2014-Jan-01-0000 "と同じくらい良いです。 – VRK
@VRK yep!それもクリーナーです –