删除与命令行上的名称递归匹配的文件(OS X)


11

最近,我试用了一个备份实用程序,并想备份MacBook(OS X)上某些网站的本地副本。

不幸的是,该实用程序在其备份的每个目录中都保留了两个文件:.shadowFileList.shadowFolderFlagPlist

现在,我已从该目录中删除了备份,但是它仍然保留了文件,我非常想摆脱这些点文件。

我并不是一个真正的命令行高级用户,但是知道这是最好的方法。我怀疑我必须将输出find传送到rm

你怎么做到这一点?

Answers:


25
% find UPMOST_RELEVANT_PATH -name ".shadowFileList" -delete

显然,对您要丢弃的任何其他文件名执行相同的操作...


我反过来需要它。我需要删除不是某个文件结尾的所有文件。怎么样?文件夹不应删除。
强尼

2
find . ! -name "*.xyz" -delete,也看到stackoverflow.com/questions/25136041/...

我最终find . -type f -not -name "*.hpp" -not -name "*.h" -not -name "*.inl" -delete保留了文件夹。
强尼
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.