You are here

Recursively delete .svn directories

Subversion is a software versioning and revision control system.
Every copy of source code received from subversion repository has .svn folders, which store metadata.

This is a simple example of a unix command, which recursively deletes subversion .svn folders, these folders are often not necessary, if you want to distribute the source code.
You can put this code at the end of your .bashrc file, in order to make it like a system command, please do not remove the other lines in the file.

skyline ~ $ cd
skyline ~ $ vi .bashrc

##
##      By: Alvaro Soto - alvaro@headup.ws
##      http://blog.headup.ws/node/17
##
##      csvn: Removes recursively all the .svn dirs 
##                  starting from a given path or from the cwd
##

csvn(){
    local dir=$1
        [ "$dir" == "" ] && dir=$(pwd)
        while true; do
            read -p "Do you wish to delete .svn dirs on [ $dir ]? " yn
            case $yn in
                [Yy]* ) find $dir -name .svn -print0 | xargs -0 rm -rf ; break;;
                [Nn]* ) break;;
                * ) echo "Please answer yes or no.";;
            esac
        done
}

##
##
##

skyline ~ $ . .bashrc
skyline ~ $ csvn 
Do you wish to delete .svn dirs on [ /Users/alvaro ]? n
skyline ~ $ 
Tags: