[英]I wanna to delete all files and directories in linux
我必须删除所有目录和文件,这些目录和文件应该比当前日期早3年,这应该是linux中的特定命令。
It depends on how you define "3 years back": created, last modified... If that's last modified, you can do something like this to list those files 这取决于您如何定义“ 3年”:创建,上次修改...如果上次修改,则可以执行以下操作以列出这些文件
find /directory -mtime +1095
/directory is the starting directory, +1095 meaning modified 1095 days ago, 365*3. / directory是起始目录,+ 1095表示1095天前修改的365 * 3。
If you're okay with the list, then add the delete option 如果您对列表满意,请添加删除选项
find /directory -mtime +1095 -delete
Be careful not to put -delete before -mtime, there's a specific order there. 注意不要将-delete放在-mtime之前,那里有特定的顺序。 See
man find
for more informations. 有关更多信息,请参见
man find
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.