I'm trying to find the command to delete recursively all Apple Mac generated files such as '._' from the drive. So far I have:

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

however it doesn't seem to do the trick.

migrated from stackoverflow.com Dec 20 '12 at 17:15

This question came from our site for professional and enthusiast programmers.

  • 1
    Sorry, this is off-topic. Try superuser.stackexchange.com – Joe Dec 20 '12 at 16:20
  • How is this off topic? Isn't ssh covered here - I've seen several posts for ssh, but none explaining how to achieve the above. – Spencer Mark Dec 20 '12 at 16:39
  • They might have been old questions. Since StackOverflow launched, lots of StackExchanges have sprung up to fill specialisms. Those questions might have appeared before that StackExchange site existed. – Joe Dec 20 '12 at 17:01
  • (I know how frustrating it is to have something marked off-topic, but it needs a number of votes from the community to confirm it so it's nothing personal.) – Joe Dec 20 '12 at 17:02
  • What do you observe? – Nicole Hamilton Dec 20 '12 at 17:23

There's now a better way!

See man dot_clean since OS X 10.5.

dot_clean -n . will not just delete the dot underbar files in and below the current directory, it'll merge their information into the parent file if it's not already there (and I infer that you want -n to also delete the dot underbar file if there is no matching native file).


Using the dot as first argument starts in the directory you are currently in.

If you want to find all files beginning with ._ you should use the slash as first parameter so that find starts at the root-directory.

And as some of these files will not be owned by you you might like to use the suso command also.

So the complete command looks like this:

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

At least for me that always does the trick. Ommiting the -exec part will simply list all files so you might run this first to see whether all files are found you expect


find . ( -name '._*' ) -exec rm {} -rf \; should work

I don't know if it's different in OSX compared to bash.

  • Macs run Bash and certainly have find although I think it's a bit out of date. The man page says 2008, but I'm sure it'll be sufficiently up to date. – Joe Dec 20 '12 at 23:03

I know: this post is obsolete. Anyway I write here because is the first I found! I had the same problem with a Dropbox account that I used on mac osx, moved now on Windows / Linux Ubuntu. Using bash (mine is the Cygwin64 bash), I typed inside my Dropbox folder:

find . -regex '.+/\._.+' -exec rm {} \;

Note that -rf was removed from above solutions. '._' are supposed to be only files, so do not add too many powers to rm command! ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy