On Mar 10, 2009, at 10:39 AM, Matt wrote:
I want to remove files but only if they are owned by a certain user and group.
Basically I have this:
find /var/spool/greylist -mmin +363 -exec rm -f {} ;
I want to make sure it only deletes files owned by mail. Basically no matter what weird characters are in the file names I want to make sure it does not delete anything outside of /var/spool/greylist. I can add 'sudo -u' to it but then my secure log gets filled with entries but perhaps thats the only way to do it.
find /var/spool/greylist -mmin +363 -mindepth 1 -depth -user mail - group <whatever> -print0 | xargs -0 rm -f
if you want to make sure you only hit files, and not directories, do this:
find /var/spool/greylist -mmin +363 -mindepth 1 -depth -user mail - group <whatever> -type f -print0 | xargs -0 rm -f
to be extra safe, and preview what files will be deleted first:
find /var/spool/greylist -mmin +363 -mindepth 1 -depth -user mail - group <whatever> -type f -print0 | xargs -0 ls -al
-steve
-- If this were played upon a stage now, I could condemn it as an improbable fiction. - Fabian, Twelfth Night, III,v