Recursively Remove .cvs/.svn/.git Directories

Recursively Remove .cvs/.svn/.git Directories

I tend to keep backups using several methods depending on the situation. Some times I run a script that invokes rsync with rolling, date-based backup. Lately I have been experimenting with compressed/dedup archives/filesystems.

One nearly constant annoyance, though, are those pesky .svn, .cvs, and .git directories. They serve a purpose, but not within my backup that already versions its data.

In order to be rid of them I just run rm -rf `find ./ -type d -name [directory to remove]`. If you wanted to, you could stick this into a script within your path:


if [ $# == 1 ]; then
rm -rf `find ./ -type d -name $1`
echo "Script requires one argument."

This would allow you to pass the directory you want to recursively be rid of in whatever directory you call it from. Note this script will not handle spaces in the argument but for this we do not need it.

Leave a Reply

Your email address will not be published. Required fields are marked *