Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSH/Shell - Remove all folders with name "____" within folder AND subfolders

Tags:

shell

ssh

I have a script that is copying a folder that contains a couple sub folders. The original that it is copying from is part of an SVN folder, so it is copying those ".svn" folders as well.

I want to remove those from the new destination, my best guess was:

rm -Rf dir/*.svn

Which doesn't work, is there a way to do this or do I need to manually go into each folder to delete it?

like image 463
Kerry Jones Avatar asked Dec 18 '22 00:12

Kerry Jones


2 Answers

From within the folder whose contents you want to filter:

find . -name '.svn' -print0 | xargs -0 rm -rf

or

find . -name '.svn' -exec rm -rf {} \;

like image 132
Wevah Avatar answered Feb 23 '23 00:02

Wevah


Take a look at this: http://snippets.dzone.com/posts/show/2486

like image 26
Matthew J Morrison Avatar answered Feb 23 '23 01:02

Matthew J Morrison