简体   繁体   中英

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

find /directory -mtime +1095

/directory is the starting directory, +1095 meaning modified 1095 days ago, 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. See man find for more informations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM