简体   繁体   English

找不到删除与日期模式匹配的文件的方法

[英]Can't find a way to delete files that match a date pattern

I'm trying to delete all files in a folder structure (recursively) except the youngest one for each month.我正在尝试删除文件夹结构中的所有文件(递归),除了每个月最年轻的文件。

In other words.... only keep the first ones from each month in each folder.换句话说....只保留每个文件夹中每个月的第一个。

On a Linux system (bash)... ;-) (or even more precise on a Synology NAS)在 Linux 系统上(bash)... ;-)(或者在 Synology NAS 上更精确)

May thanks for your help !感谢您的帮助! Alex亚历克斯

Please be careful!请小心! I take no responsibility!我不承担任何责任!

Try find :尝试find

Remove files which are older than 7 days:删除超过 7 天的文件:

find . -type f -ctime +7 -delete

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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