help with command line deletion

LuKreme kremels at kreme.com
Thu Apr 19 18:38:21 PDT 2007


On 19-Apr-2007, at 03:44, Norman Gray wrote:
> On 2007 Apr 18 , at 22.57, LuKreme wrote:
>> On 18-Apr-2007, at 09:39, Martin Costabel wrote:
>>> Or use the -delete flag:
>>
>> When did the find included in OS X start supporting -delete  
>> though?  I learned the -exec rm {} \; syntax specifically because  
>> I couldn't use -delete
>
> This sort of thing is why I prefer the general technique of piping  
> 'find's output to something else to do the work (in this case, the  
> deletion).  That way, I don't have to worry about whether this  
> Unix's find has some funky flag or not, and I don't have to read  
> the find manpage (again) to remind myself of the syntax, and try to  
> remember how I'm supposed to escape the {}, and whether I need the  
> \; or not, and whether -delete deletes a directory's contents  
> before the directory itself.

Yep, but it's not that simple, you can't simply pipe to rm, so you  
have to learn a whole different syntax involving -print0 for find and  
xargs -0 to process the list, so you're really not gaining much,  
especially since as it turns out, -delete has been part of OS X since  
at least 10.2

> Tools are supposed to be orthogonal -- find finds things.

if this worked, I'd agree with you:

% find . -name trash.bak | rm

but it doesn't.

-- 
Can I tell you the truth? I mean this isn’t like TV news, is it?




More information about the MacOSX-admin mailing list