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!
相关问题
- How to get the return code of a shell script in lu
- Invoking Mirth Connect CLI with Powershell script
- Xcode debugger displays incorrect values for varia
- Is there a way to report errors in Apple documenta
- Why should we check WIFEXITED after wait in order
相关文章
- 使用2台跳板机的情况下如何使用scp传文件
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- In IntelliJ IDEA, how can I create a key binding t
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
I use this command to delete empty directories. It starts at the bottom and works its way to the top. So, it won't doesn't fail if you reference the current path.
Ruby(1.9+)
find . -name ".*" -print
I don't know the MAC OS, but that is how you find them all in most *nix environments.
find . -name ".*" -exec rm -rf {} \;
to get rid of them... do the first find and make sure that list is what you want before you delete them all.
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.You need to be very careful and test any commands you use since you probably don't want to delete the current directory (
.
), the parent directory (..
) or all files.This should include only files and directories that begin with a dot and exclude
.
and..
.I found this to work quite well (in Bash on Linux at least):
You can tweak the regular expression in the
sed
call to your likings.Be careful though: in my case, I have a lot of hidden files named
.gitignore
or.gitkeep
that must be preserved. Be sure to check the list to see if anything is in there that you want to keep.I've found this variant to be quite useful, it removes files like
._ANYTHING
(often trashed or tmp files):If you want to delete directories, change
-type f
fortype -d
.If you want to delete files and directories remove
type -f