I recently replaced the default macOS (El Capitan) with Ubuntu 16.10 (on a MacBook Pro 11.1, and backed up all my documents to an external drive.

When I migrated all my documents back from the drive, I ended up with a lot of ._ files (including ._DS_Store, ._.DS_Store, and copies of several documents starting with ._ followed by the original document name.

I would like to get rid of all those files. I tried Bleachbit, but that one apparently only finds the ._DS_Store files, not the other types. I am especially interested in figuring out a way to safely delete all these ._ duplicates of my documents. Also, all these ._ files are scattered around on several different folders and sub-folders, so I would like to be able to make a system-wide search to spot them and delete them, without deleting anything that I actually care about.

Could anyone recommend the best way to do this? Thanks

  • 5
    Very carefully. Typoing this is possibly the most common way to accidentally erase your hard drive. – Mark Nov 2 '16 at 21:15

Using find, from the parent, recursively:

find . -type f -name '._*'

After checking append -delete to remove the files:

find . -type f -name '._*' -delete

Using bash, from parent directory:

shopt -s globstar  ## Enables recursive glob match
for f in **/._*; do [[ -f $f ]] && echo "$f"; done

After checking, do:

for f in **/._*; do [[ -f $f ]] && rm "$f"; done
shopt -u globstar
  • 3
    Thanks a lot! That worked perfectly. I'll accept the answer as soon as the site lets me... – user53330 Nov 2 '16 at 13:27

Your Answer

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