Quantcast
Channel: Linux by Examples » find
Viewing all articles
Browse latest Browse all 7

Remove all .svn directories at once

$
0
0

When you check out a project code base from a svn repository, each downloaded directory (from top to the deepest) contains a .svn hidden directory that keeps svn’s necessary metadata.

If you want to remove them all at once, here’s one way to do it:

 ~/project_dir $> find -name .svn -print0 | xargs -0 rm -rf

find -name .svn searches the current directory hierarchy for files named .svn.

-print0 ensures each filename ended with a null character. This allows filenames that contain newlines/whitespaces to be interpreted correctly by programs that consume the output.

xargs -0 rm -rf receives the output and passes it to rm for file removal. Remember to use -0 option when the input items are terminated by a null character.

Update: Thanks to geek00L, actually find alone is sufficient:

find /project_dir -type d -name .svn -exec rm -rf '{}' +

Update: svn export should be the right tool that does the job (thanks to aizatto):

svn export project_dir new_dir

Viewing all articles
Browse latest Browse all 7

Trending Articles