您可以将时间戳记作为文件,并将其用作参考点:
例如,2014年1月1日:
touch -t 201401010000 /tmp/2014-Jan-01-0000
find /path -type f ! -newer /tmp/2014-Jan-01-0000 | xargs rm -rf
之所以有效,是因为我们正在使用find
一个-newer
开关。
来自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.