问题描述
有一个名为X的文件夹位于根目录Y的多个子文件夹中。我想删除Y中存在的所有名为X的文件夹,它们都是子文件夹。我想使用 osx终端来执行此操作。
该文件夹可以位于任何级别的Y任意位置,所以我想使用一种比仅使用 rm -r
为我找到的每个位置。
cd到目录Y的根目录 b
$ b
then假设文件夹名称为X,输入):
find。-name X -exec rm -rf {} \;
(并且非常小心,您从哪里开始这个 find
,您只需要在Y目录中执行此操作。
我一直在做这种事情来删除旧的/破坏的存储库目录(如 .svn
),我怀疑是你也可以做的。
现在可能是一个聪明的时候,我提醒你,时间机器是一个在Macintosh上启用的好东西。
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.
"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.
这篇关于如何使用osx终端删除目录中的文件夹名称X的所有文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!