find files older than X days in bash and delete

后端 未结 2 1983
[愿得一人]
[愿得一人] 2020-11-28 12:26

I have a directory with a few TB of files. I\'d like to delete every file in it that is older than 14 days.

I thought I would use find . -mtime +13 -delete

相关标签:
2条回答
  • 2020-11-28 12:58
    find your/folder -type f -mtime +13 -exec rm {} \;
    
    0 讨论(0)
  • 2020-11-28 13:17

    This works for me.

    $ find ./folder_name/*  -type f -mtime +13 -print | xargs rm -rf
    
    0 讨论(0)
提交回复
热议问题