I have this bash script here
#!/bin/bash
find /Users/ -name "*.mov" -o -name "*.flv" -o -name "*.mp4" -o -name "*.avi" -o -name "*.wmv" -o -name "*.mpeg" -o -name "*.avi" -o -name "*.wmv" -o -name "*.f4v" -o -name "*.m4v" -o -name "*.mxf" -o -name "*.ts" -type f -mtime +7 -exec rm -rf {} \;
It finds all the files that are older than 7 days, and that works fine, but when I want it to remove the result set that I found it doesn’t delete any of the files. Is there something I’m doing wrong? This is on Mac OSX 10.6
Any help would be great. Thanks!
Instead, of
-exec rm -rf {}\;, try the-deleteoption if it’s available on your version of thefindcommand. This will show an error message after each failed attempt to delete. That might give you more information what’s going on.Neither
findis returning the actual exit code from the delete/rm command. You may want to do something like this:That might give you a better understanding of what’s going on.