'Bash script to delete certain files from "semi-sequentially" numbered directories?
I have directories that are sequentially numbered 1001, 1002, 1003, etc... Some directories may not exist so we may see instances like 1001, 1002, 1003, 1007, 1008, etc... and I want to delete all files within those directories that are over 2 years (730 days) old. Can someone point me in the right direction to write a bash script to automate the process?
I have what I think are 2 parts to the puzzle but I am not able to make them work together...
find numbered directories: for i in $(seq 1000 1999)
files older than 2 years: find /path/to/base/dir/* -type d -ctime +730 -exec rm -rf {} ;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|