💻 Software
Bash script to delete files older than x days with subdirectories
Fresh7 days ago
Mar 15, 202695728 viewsConfidence Score0%
0%
Problem
I'm trying to delete a ton of files older than x days. Now I have a script to do that But this will also delete the subdirectories. There are a ton of folders but I would like to keep them, and delete the files older than 10 days within the said folders. Is there a way to do this?
Error Output
find /path/to/files* -mtime +10 -exec rm {} \;Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: Bash script to delete files older than x days with subdirectories
Low Risk
option for filtering results accepts the option for selecting, for example, only files. Leave out to show what it'd delete, and once you've verified that, go ahead and run the full command. That would only run on files, not directories. Use for the …
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix