Is there a way to tell rm -f to only remove a file if its owned by say mail? Matt
On 10/26/2010 05:23 PM, Matt wrote:> Is there a way to tell rm -f to only remove a file if its owned by say mail?Not sure you can directly use rm for that, but you could find the uid of the user in /etc/passwd, then run find and -exec on it with rm. To view them: cat /etc/passwd | grep "USER" find /path -uid 123 -exec ls -la {} \; To delete them, then use -exec rm -rf {} \; Be CAREFUL though! Regards, Max
Matt wrote:> Is there a way to tell rm -f to only remove a file if its owned by say > mail?find <path> -user mail -exec rm -f {} \; man find. mark
On Tue, 26 Oct 2010, Matt wrote:> Is there a way to tell rm -f to only remove a file if its owned by say mail?find . -user "$USERMATCH"-name "$FILENAME" \ -a -exec rm -f {} \; or such ... -- Russ herrold
On 26.10.10 23:23, Matt wrote:> Is there a way to tell rm -f to only remove a file if its owned by say mail? > > Mattmaybe something like this (untested) #$ find /path -type f -a -user mail -exec rm {} \; -- Best Regards, Markus Falb -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 259 bytes Desc: OpenPGP digital signature URL: <http://lists.centos.org/pipermail/centos/attachments/20101026/939d6242/attachment-0001.sig>