[CentOS] rm user:group

Tue Mar 10 14:59:39 UTC 2009
Steve Huff <shuff at vecna.org>

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



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2209 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos/attachments/20090310/5eb324c4/attachment-0003.p7s>