Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm still learning the bash shell.

I want to recursively find and remove svn files within the child directories of a given folder. I made the mistake of checking out instead of just cloning. So i'm trying to clean up my mess.

I've tried these but i've only get output of all the files found:

rm | find -name ".svn"

When i run this i get no output and the files are still there: find . -executable -o ! -regex '.*\.svn' -exec rm -i {} \+

share|improve this question

3 Answers 3

up vote 10 down vote accepted

The easier method would be to export the revision you want instead of checking it out. Try svn help export at the bash shell.

If you really want to use find to go through and remove all child directories called .svn you would do this:

find /path/to/search -type d -iname .svn -print0 | xargs -0 rm

EDIT

  • -type d #look for directories only
  • -iname .svn #case insensitive matching, probably not necessary
  • -print0 #prints the full file name followed by a null character instead of newlines. it allows file names with spaces or other whitespace to be passed properly to xargs -0
share|improve this answer
    
Yeah i made the mistake of not exporting so i'm trying to clean up my mess. I'll give that a try. Could you break down what you did in the command? –  chrisjlee Jul 25 '11 at 17:10
    
Thanks for the breakdown that helped a lot! –  chrisjlee Jul 25 '11 at 17:19
    
Glad to help out! :) –  Sean C. Jul 25 '11 at 17:24
3  
Shouldn't that be rm -r? Plain old rm won't remove directories. Also, I'd recommend the -prune switch to find here: rm -r already deletes all subdirectories, so there's no need to traverse them. –  Ilmari Karonen Jul 25 '11 at 19:17
    
find . -type d -iname .svn -print0 | xargs -0 rm -rf –  InquilineKea Sep 18 '11 at 19:37
shopt -s globstar
rm -r **/.svn
share|improve this answer

Most versions of find have a delete action:

$ find /path/in/question -type d -name .svn -delete

Make sure you run it without the delete and look over the results first!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.