[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: removing .svn files from local copy

From: Matt Doran <matt.doran_at_papercut.biz>
Date: 2006-05-29 03:22:19 CEST

Bob Proulx wrote:
> Matt Doran wrote:
>
>> That works. But the 'find' way of doing this is cleaner.
>>
>>> find . -name .svn | xargs rm -rf
>>>
>>> I almost always use zero terminated strings with find and xargs.
>>>
>>> find . -name .svn -print0 | xargs -r0 rm -rf
>>>
>> Or an even more findy way to do it ...
>>
>> find . -name .svn -exec rm -rf {} \;
>>
>> ;)
>>
>
> Well, actually, no, not quite. Sure it is completely contained in
> find. But doing it that way is slower and less efficient than find
> plus xargs. It executes rm once for each file. That is much less
> efficient than using find plus xargs to run find (probably only once)
> with as large of an argument list as possible. The find and xargs
> programs are designed to work together and make a great pair. That is
> a very fast and efficient combination.
>
> If you want to use only find but still be efficient and execute rm as
> few times as possible then you need to look at the spiffy new POSIX
> find "-exec {} +" syntax. Here is the snippet from gnu find's manual.
>
> -exec command {} +
> This variant of the -exec option runs the specified command on
> the selected files, but the command line is built by appending
> each selected file name at the end; the total number of invoca-
> tions of the command will be much less than the number of
> matched files. The command line is built in much the same way
> that xargs builds its command lines. Only one instance of ’{}’
> is allowed within the command. The command is executed in the
> starting directory.
>
> So using this the command becomes:
>
> find . -name .svn -exec rm -rf {} +
>
> This is a pretty new feature and not all GNU find installations will
> have this feature yet. I still use find plus xargs most of the time.
>
> Bob
>
>
>
You win! ;)
Received on Mon May 29 03:23:37 2006

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.