Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove all folders with foldername X within a directory using osx terminal [closed]

There is a folder named X located within a number of subfolders of root directory Y. I want to delete all folders named X that are present in Y and all of it's subfolders. I want to do this using osx Terminal.

The folder can be located anywhere downstream of Y at any level, so I want to use a more systematic approach than just using rm -r for every locations I find.

like image 830
Oliver Avatar asked Apr 03 '13 10:04

Oliver


1 Answers

"cd" to root of directory Y

then (assuming the folder name is "X", type in):

"find . -name X -exec rm -rf {} \;" (and be incredibly careful about where you start this "find" from... you only want to do this within your Y directory).

I do this kind of thing all the time to remove old/busted repository directories (like ".svn"), which I suspect is what you may also be doing as well.

And now would probably be a smart time for me to remind you that "Time Machine" is a great thing to have enabled on your Macintosh.

like image 157
Michael Dautermann Avatar answered Oct 01 '22 06:10

Michael Dautermann