在Linux中删除早于特定日期的文件

在Linux中删除早于特定日期的文件,第1张

在Linux中删除早于特定日期的文件

您可以将时间戳记作为文件,并将其用作参考点:

例如,2014年1月1日:

touch -t 201401010000 /tmp/2014-Jan-01-0000find /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.


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4962343.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-13
下一篇2022-11-13

发表评论

登录后才能评论

评论列表(0条)

    保存