---
title: "按时间删除文件---linux命令小记"
author: "kantery"
date: "2009-12-29T16:51:43Z"
tags: []
categories: ["操作系统"]
slug: "linux"
draft: false
lastmod: "2009-12-29T16:52:06Z"
id: 559269
url: "https://kantery.iteye.com/blog/559269"
---

创建一个标准文件 time_file
1. touch -t 01010000 time_file
然后删除不新于（! -newer） 这个文件的所有文件
2. find . ! -newer time_file | xargs rm
然后删除新于这个文件的所有文件
3.find .  -newer time_file | xargs rm
如果不能删除则加上强制：
如：
touch -t 12290000 new.txt
find . -newer new.txt | xargs rm <span style="color:red">-rf</span>