Recursively Delete Subversion (.svn) Directories

I alway am hunting for this little command-line gem, so I figured I’d post it and share the quick shell script I added to my home directory to make it faster for me to do this.

Often, I will find an old project (or inherit, or destroy) a project with subversion directories and files in it. However I get there, every few months I find myself wanting to remove subversion folders recursively and am not well-versed in shell scripting to remember how to do it.

Here’s the single line magic removal of .svn directories:

rm -rf `find . -type d -name .svn`

And here’s the script I wrote and placed in my home directory, ~/recursively-kill-svn.sh:

while true; do
	read -p "Do you want to recursively delete all .svn folders/files in the current directory (`pwd`)? (y/n)" yn
	case $yn in

		[Yy]* ) rm -rf `find . -type d -name .svn`; echo ".svn directories in `pwd` have been recursively killed!!1"; break;;

		[Nn]* ) echo "I've done absolutely nothing."; exit;;
		* ) exit;
	esac
done

With this in my home directory, I just move to a project folder, type:

~/recursively-kill-svn.sh

…and hit enter. Enjoy.

P.S. If it’s not working for you (or auto-completing when you hit tab in Terminal) make sure it has permissions to execute:

chmod +x ~/recursively-kill-svn.sh

P.P.S. You can rename the file to whatever you like.

你可能感兴趣的:(subversion)