如何在UNIX上递归删除目录中的所有隐藏文件? [英] How do you recursively delete all hidden files in a directory on UNIX?

查看:156
本文介绍了如何在UNIX上递归删除目录中的所有隐藏文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了一段时间,但似乎无法获得简洁的解决方案.我有一台Mac,其中有一个文件夹,我想清除所有隐藏的文件/目录-任何隐藏的东西.它曾经是带有许多.metadata/.svn内容的Eclipse工作区,并且我将其全部删除都很好.如何执行此操作(使用Shell脚本,Applescript等).在此先多谢!

I have been searching for a while, but can't seem to get a succinct solution. I have a Mac with a folder that I want to clean of all hidden files/directories - anything hidden. It used to be a Eclipse workspace with a lot of .metadata/.svn stuff, and I'm fine with all of it being removed. How can I do this (either with a shell script, Applescript, etc). Thanks a lot in advance!

推荐答案

find . -name ".*" -print

我不知道MAC OS,但是那是您在大多数* nix环境中找到它们的全部方式.

I don't know the MAC OS, but that is how you find them all in most *nix environments.

find . -name ".*" -exec rm -rf {} \;

要摆脱它们... 先进行查找并确保列表是您想要的,然后再将其全部删除.

第一个"."表示当前目录中的.还要注意,第二个".*"可以更改为".svn*"或任何其他更特定的名称;上面的语法仅查找所有隐藏文件,但是您可以更具选择性.我一直使用它来删除旧代码中的所有.svn目录.

The first "." means from your current directory. Also note the second ".*" can be changed to ".svn*" or any other more specific name; the syntax above just finds all hidden files, but you can be more selective. I use this all the time to remove all of the .svn directories in old code.

这篇关于如何在UNIX上递归删除目录中的所有隐藏文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆