How do you recursively delete all hidden files in a directory on UNIX?

后端 未结 6 1518
谎友^
谎友^ 2021-02-01 03:42

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.

6条回答
  •  一个人的身影
    2021-02-01 03:59

    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.

提交回复
热议问题