Re: Best (most efficient method) recursive dir DEL

Kyle <[email protected]> Fri, 23 May 2014 06:11:27 +1000
Newsgroups gmane.org.user-groups.slug.general
Message-ID <[email protected]>
Thanks to all for the responses.

Interestingly, everyone has come back with "find" (followed by......) as 
the best option. Perhaps this is simply a reflection of the fact my 3 
examples all used 'find'.

I have always thought (believed) 'find' was a less efficient process 
than 'locate' and kind of hoped 'locate' (or some other cmd I don't 
know) might pop up as a solution. I understand 'locate' depends on an 
updated 'db', but I figured that indexing process was still more 
efficient than 'find' trawling the structure in realtime.

Kyle


On 22-05-2014 19:16, Darragh Bailey wrote:
> Hi Kyle,
>
> You might find it worth looking at the following invocation of find:
>
> find <top_dir> -name <name_to_del> -exec rm -rf {} \+ -prune
>
> the '+' will support expansion of arguments, thus it works exactly 
> like xargs in building up a command line that is passed to rm. You may 
> also need to specify \"{}\" to handle whitespace in directory names, 
> untested.
>
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html