Linux删除指定日期之前的文件

删除指定日期之前的文件,

  • 首先,创建一个基准时间文件touch -t 202301010000 time_file,
  • 然后查看日期是否正确ll --time-style=long-iso time_file
  • 最后执行删除命令find . ! -newer time_file | xargs rm

如下所示:

touch -t 202301010000 time_file
ll --time-style=long-iso time_file
find . ! -newer time_file | xargs rm

在这里插入图片描述
删除文件大小为0的文件

find . -name "*" -type f -size 0c | xargs -n 1 rm -f

在这里插入图片描述

参考资料
【Linux】Linux中删除指定日期之前的文件

你可能感兴趣的:(Linux,linux,运维,服务器)