歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Liunx 按日期刪除文件

Liunx 按日期刪除文件

日期:2017/3/2 10:06:30   编辑:關於Linux

1,先創建一個2009年12月31號12點的文件

touch -t 200912311200 temp

2,查找比temp這個文件舊的文件

find . ! -newer temp|xargs ls

查看一下是否是你要刪除的文件,如果是執行下面的方法刪除

3,查找並刪除
find . ! -newer temp|xargs rm
上面命令查找2009年12月31號12點前的文件並刪除

注:!表示邏輯非 ,

如:find . -newer temp 表示查當前文件夾下比temp新的文件

如果加上就表示查找比temp舊的文件

Copyright © Linux教程網 All Rights Reserved