您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

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

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

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

例如,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.
其他 2022/1/1 18:20:01 有507人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶