[lug] Removing hidden directory recursively

Garett Shulman shulmang at colorado.edu
Fri Apr 21 15:00:31 MDT 2006


Also... here is some Ruby from a coworker that will do it.

#!/usr/local/bin/ruby
require 'fileutils'
require 'find'
include Find
include FileUtils
         
d = ARGV.shift or abort "#{ $0 } dir"
find(d){|e|chmod 0666, e and rm_rf e if e =~ %r/.svn$/}


Garett Shulman wrote:
> I'de like to see a unix one-liner for this. However when I need to do 
> this I use the following python function...
>
> def rmsvn(current_dir):
>        for current_dir_item in os.listdir(current_dir):
>                try:
>                        os.chdir(current_dir + "/" + current_dir_item)
>                        if current_dir_item == ".svn":
>                                os.system("rm -rf " + current_dir + "/" 
> + current_dir_item)
>                        else:                                 
> rmsvn(current_dir + "/" + current_dir_item)
>                except:
>                        continue
>
>
> Paul Nowosielski wrote:
>> Dear All,
>>
>> I'm trying to remove 1000's of .svn files from a web directory. Can 
>> any one give me a tip on how to do this with a one line command?
>>
>> Best,
>>
>>   
>
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug




More information about the LUG mailing list