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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值